local extension = Package:new("ysch2")
extension.extensionName = "ysch_Al"

local U = require "packages/utility/utility"
Fk:loadTranslationTable{
    ["west"] = "西",
    ["AOV"] = "耀",
    ["delta"] = "三角洲",
    ["Russia"] = "俄",
}

-- 将一张牌给某角色蓄谋
--先把半成品蓄谋放在这里，铝宝智慧不靠其他扩展……
---@param player ServerPlayer @ 操作蓄谋的玩家
---@param card integer | Card  @ 用来蓄谋的牌
---@param skill_name? string @ 技能名
---@param proposer? integer @ 移动操作者的id
---@return nil
local premeditate = function(player, card, skill_name, proposer)
    skill_name = skill_name or ""
    proposer = proposer or player.id
    local room = player.room
    if type(card) == "table" then
      assert(not card:isVirtual() or #card.subcards == 1)
      card = card:getEffectiveId()
    end
    local xumou = Fk:cloneCard("ysch_Al__premeditate")
    if Fk.skills["#premeditate_rule"] then
        xumou = Fk:cloneCard("premeditate")
    elseif Fk.skills["#tuntian_premeditate_rule"] then
        xumou = Fk:cloneCard("tuntian__premeditate")
    end
    xumou:addSubcard(card)
    room:sendLog{
      type = "#premeditate",
      from = proposer,
      to = {player.id},
    }
    player:addVirtualEquip(xumou)
    room:moveCardTo(xumou, Player.Judge, player, fk.ReasonJustMove, skill_name, nil, false, proposer, "", {proposer, player.id})
end
if not Fk.skills["#rfenghou__premeditate_rule"] and not Fk.skills["#premeditate_rule"] and not Fk.skills["#tuntian_premeditate_rule"] then
    local premeditate_rule = fk.CreateTriggerSkill{
        name = "#rfenghou__premeditate_rule",
        events = {fk.EventPhaseStart},
        mute = true,
        global = true,
        priority = 0,
        can_trigger = function(self, event, target, player, data)
            return target == player and player.phase == Player.Judge
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local cards = player:getCardIds(Player.Judge)
            for i = #cards, 1, -1 do
                if table.contains(player:getCardIds(Player.Judge), cards[i]) then
                if player.dead then return end
                local xumou = player:getVirualEquip(cards[i])
                if xumou and xumou.trueName == "premeditate" then
                    local use = U.askForUseRealCard(room, player, {cards[i]}, ".", "premeditate",
                    "#premeditate-use:::"..Fk:getCardById(cards[i], true):toLogString(),
                    {expand_pile = {cards[i]}, extra_use = true}, true, true)
                    if use then
                    room:setPlayerMark(player, "premeditate_"..use.card.trueName.."-phase", 1)
                    use.extra_data = use.extra_data or {}
                    use.extra_data.premeditate = true
                    room:useCard(use)
                    else
                    break
                    end
                end
                end
            end
            cards = player:getCardIds(Player.Judge)
            local xumou = table.filter(cards, function(id)
                local card = player:getVirualEquip(id)
                return card and card.name == "rfenghou__premeditate"
            end)
            room:moveCardTo(xumou, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, "premeditate", nil, true, player.id)
        end,
    }
    local premeditate_prohibit = fk.CreateProhibitSkill{
        name = "#rfenghou__premeditate_prohibit",
        global = true,
        prohibit_use = function(self, player, card)
            return card and player:getMark("premeditate_"..card.trueName.."-phase") > 0
        end,
    }
    local premeditate_visible = fk.CreateVisibilitySkill{
        name = "#rfenghou__premeditate_visible",
        global = true,
        card_visible = function(self, player, card)
            local owner = Fk:currentRoom():getCardOwner(card.id)
            if owner then
                local vcard = owner:getVirualEquip(card.id)
                if vcard and vcard.name == "rfenghou__premeditate" then
                return false
                end
            end
        end
    }
    Fk:addSkill(premeditate_rule)
    Fk:addSkill(premeditate_prohibit)
    Fk:addSkill(premeditate_visible)
    Fk:loadTranslationTable{
        ["#premeditate"] = "%from 对 %to 进行了蓄谋",
        ["#premeditate-use"] = "你可以使用此蓄谋牌%arg，或点“取消”将所有蓄谋牌置入弃牌堆",
    }
end
local getAllCardNames = function(card_type, true_name)
    local all_names = {}
    local basics = {}
    local normalTricks = {}
    local delayedTricks = {}
    local equips = {}
    for _, card in ipairs(Fk.cards) do
        if card.package and not table.contains(Fk:currentRoom().disabled_packs, card.package.name) and not card.is_derived then
            if card.type == Card.TypeBasic then
                table.insertIfNeed(basics, true_name and card.trueName or card.name)
            elseif card.type == Card.TypeTrick and card.sub_type ~= Card.SubtypeDelayedTrick then
                table.insertIfNeed(normalTricks, true_name and card.trueName or card.name)
            elseif card.type == Card.TypeTrick and card.sub_type == Card.SubtypeDelayedTrick then
                table.insertIfNeed(delayedTricks, true_name and card.trueName or card.name)
            elseif card.type == Card.TypeEquip then
                table.insertIfNeed(equips, true_name and card.trueName or card.name)
            end
        end
    end
    if card_type:find("b") then
        table.insertTable(all_names, basics)
    end
    if card_type:find("t") then
        table.insertTable(all_names, normalTricks)
    end
    if card_type:find("d") then
        table.insertTable(all_names, delayedTricks)
    end
    if card_type:find("e") then
        table.insertTable(all_names, equips)
    end
    return all_names
end
---@param player ServerPlayer @ 目标角色
local DIYEnterHidden = function (player)
    local room = player.room
    room:sendLog({
      type = "#EnterHidden",
      from = player.id,
    })
    local skills = "hidden_skill&"
    room:setPlayerMark(player, "__hidden_general", player.general)
    for _, s in ipairs(Fk.generals[player.general]:getSkillNameList(true)) do
      if player:hasSkill(s, true) then
        skills = skills.."|-"..s
      end
    end
    if player.deputyGeneral ~= "" then
      room:setPlayerMark(player, "__hidden_deputy", player.deputyGeneral)
      for _, s in ipairs(Fk.generals[player.deputyGeneral]:getSkillNameList(true)) do
        if player:hasSkill(s, true) then
          skills = skills.."|-"..s
        end
      end
    end
    player.general = "hiddenone"
    player.gender = General.Male
    room:broadcastProperty(player, "gender")
    if player.deputyGeneral ~= "" then
      player.deputyGeneral = ""
    end
    player.kingdom = "jin"
    room:setPlayerMark(player, "__hidden_record",
    {
      maxHp = player.maxHp,
      hp = player.hp,
    })
    player.maxHp = 1
    player.hp = 1
    for _, property in ipairs({"general", "deputyGeneral", "kingdom", "maxHp", "hp"}) do
      room:broadcastProperty(player, property)
    end
    room:handleAddLoseSkills(player, skills, nil, false, true)
end

--添加英文到中文的翻译
Fk:loadTranslationTable{
    ["#EnterHidden"] = "%from 进入隐匿状态",
  ["ysch2"] = "叶生尘寰",--小包名
}

local huangquan = General:new(extension, "ysch2__huangquan", "west", 3, 4, General.Female)--
local huangquan2 = General:new(extension, "ysch2__huangquan2", "west", 3, 4, General.Female)--
local huangquan3 = General:new(extension, "ysch2__huangquan3", "west", 3, 4, General.Female)--
huangquan2.total_hidden = true
huangquan3.total_hidden = true
Fk:loadTranslationTable{
    ["ysch2__huangquan"] = "黄泉",
    ["ysch2__huangquan2"] = "黄泉",
    ["ysch2__huangquan3"] = "黄泉",
    ["#ysch2__huangquan"] = "祭祀過往",
    ["designer:ysch2__huangquan"] = "铝",
    ["cv:ysch2__huangquan"] = "菊花花",
    ["illustrator:ysch2__huangquan"] = "星穹铁道",
}
local nailuo = fk.CreateTriggerSkill{
    name = "ysch2_nailuo",
    anim_type = "drawcard",
    events = {fk.CardUsing},
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and target == player and ( data.tos == nil or #data.tos == 0) and player:usedSkillTimes(self.name, Player.HistoryRound) == 0
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local choices = {}
        for i = 1, 5, 1 do
            table.insert(choices, "ysch2_nailuo_draw" .. tostring(i))
        end
        table.insert(choices, "Cancel")
        local choice = room:askForChoice(player, choices, self.name, "#ysch2_nailuo-draw")
        if choice ~= "Cancel" then
            self.cost_data = choice
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local x = tonumber(string.sub(self.cost_data, 18, 18))
        room:setPlayerMark(player, "@ysch2_nailuo", x)
        if player.general == "ysch2__huangquan" then
            player.general = "ysch2__huangquan2"
            room:setPlayerMark(player, "#ysch2__huangquan_showGeneral", "ysch2__huangquan2")
            room:broadcastProperty(player, "general")
        end
        if player:getHandcardNum() < x then
            room:drawCards(player, x - player:getHandcardNum(), self.name)
        end
    end,

    refresh_events = {fk.AfterDrawInitialCards,fk.CardUsing,fk.GameFinished},
    can_refresh = function(self, event, target, player, data)
        if event == fk.GameFinished then
            return player:getMark("#ysch2__huangquan_showGeneral") == "ysch2__huangquan2"
        end
        if event == fk.AfterDrawInitialCards then
            return player:hasSkill(self) and target == player
        end
        return player:getMark("@ysch2_nailuo") > 0 or event ~= fk.CardUsing
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        if event == fk.GameFinished then
            if player.general == "ysch2__huangquan2" then
                player.general = "ysch2__huangquan"
                room:setPlayerMark(player, "#ysch2__huangquan_showGeneral", "ysch2__huangquan")
                room:broadcastProperty(player, "general")
            end
        else if event == fk.AfterDrawInitialCards then
                player:chat("为寻索，为顿悟，为存在…人行于命途之上。")
                room:broadcastPlaySound("./packages/ysch_Al/audio/show/ysch2__huangquan")
            else if event ==fk.CardUsing then
                    room:removePlayerMark(player, "@ysch2_nailuo")
                    if player:getMark("@ysch2_nailuo") == 0 then
                        if player:getMark("#ysch2__huangquan_showGeneral") == "ysch2__huangquan2" then
                            player.general = "ysch2__huangquan"
                            room:setPlayerMark(player, "#ysch2__huangquan_showGeneral", "ysch2__huangquan")
                            room:broadcastProperty(player, "general")
                        end
                    end
                    table.forEach(table.filter(room.alive_players, function(p)
                        return p:getMark("@@ysch2_nailuo-turn") == 0
                    end), function(p)
                        room:setPlayerMark(p, "@@ysch2_nailuo-turn", 1)
                    end)
                    room.logic:getCurrentEvent():addCleaner(function ()
                        table.forEach(room.alive_players, function(p)
                            room:setPlayerMark(p, "@@ysch2_nailuo-turn", 0)
                        end)
                    end)
                end
            end
        end
    end,
}
local nailuo_invalidity = fk.CreateInvaliditySkill {
    name = "#ysch2_nailuo_invalidity",
    invalidity_func = function(self, from, skill)
      return from:getMark("@@ysch2_nailuo-turn") > 0
    end,
}
nailuo:addRelatedSkill(nailuo_invalidity)
huangquan:addSkill(nailuo)
local canmeng = fk.CreateViewAsSkill {
    name = "ysch2_canmeng",
    mute = true,
    anim_type = "control",
    pattern = "nullification",
    prompt = "#ysch2_canmeng",
    card_filter = function(self, to_select, selected)
        return #selected == 0
    end,
    view_as = function(self, cards, player)
        if #cards ~= 1 and #Self:getCardIds({Player.Hand, Player.Equip}) > 0 then return end
        local card = Fk:cloneCard("nullification")
        card.skillName = self.name
        if #cards ~= 0 then card:addSubcard(cards[1]) end
        return card
    end,
    enabled_at_response = function (self, player, response)
        return not response and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
    end,
}
local canmeng_prohibit = fk.CreateProhibitSkill{
    name = "#ysch2_canmeng_prohibit",
    prohibit_use = function(self, player, card)
        return player:getMark("@@ysch2_canmeng") ~= 0
    end,
    prohibit_response = function(self, player, card)
        return player:getMark("@@ysch2_canmeng") ~= 0
    end,
    prohibit_discard = function (self, player, card)
        return player:getMark("@@ysch2_canmeng") ~= 0
    end
}
local canmeng_use = fk.CreateTriggerSkill{
    name = "#ysch2_canmeng_use",
    refresh_events = {fk.PreCardUse},
    can_refresh = function(self, event, target, player, data)
        return target == player and data.card.skillName == "ysch2_canmeng"
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        room:notifySkillInvoked(player,"ysch2_canmeng","control")
        player:broadcastSkillInvoke("ysch2_canmeng",math.random(1,2))
        room:setPlayerMark(player, "@@ysch2_canmeng", 1)
        room.logic:getCurrentEvent():addCleaner(function ()
            room:setPlayerMark(player, "@@ysch2_canmeng", 0)
        end)
    end,
}
local canmeng_effect = fk.CreateTriggerSkill{
    name = "#ysch2_canmeng_effect",
    refresh_events = {fk.CardUseFinished},
    can_refresh = function(self, event, target, player, data)
        return target == player and data.card.skillName == "ysch2_canmeng" and not player:isNude()
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function(e)
            for _, move in ipairs(e.data) do
              if move.from then
                for _, info in ipairs(move.moveInfo) do
                  if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
                    room:setPlayerMark(room:getPlayerById(move.from), "_ysch2_canmeng-phase", 1)
                  end
                end
              end
            end
        end, Player.HistoryTurn)
        --if table.contains({"ysch2__huangquan","ysch2__huangquan2"},player.general) then
            if player:getMark("#ysch2__huangquan_showGeneral") == 0 then
                room:setPlayerMark(player, "#ysch2__huangquan_showGeneral", player.general)
            end
            player.general = "ysch2__huangquan3"
            room:broadcastProperty(player, "general")
        --end
        local _,dat = player.room:askForUseActiveSkill(player, "ysch2_canmeng_active", "#ysch2_canmeng_active", false)
        if dat then
            if #dat.cards==1 then
                if player:getMark("#ysch2__huangquan_showGeneral") ~= 0 then
                    player.general = player:getMark("#ysch2__huangquan_showGeneral")
                    room:broadcastProperty(player, "general")
                end
                room:throwCard(dat.cards, self.name, player, player)
            else
                player:broadcastSkillInvoke("ysch2_canmeng",math.random(3,4))
                player.room:sortPlayersByAction(dat.targets)
                room:recastCard(dat.cards, player, self.name)
                for _, pid in ipairs(dat.targets) do
                    local to = room:getPlayerById(pid)
                    if not to.dead then
                      room:damage{
                        from = player,
                        to = to,
                        damage = 1,
                        damageType = fk.ThunderDamage,
                        skillName = self.name,
                      }
                    end
                end
                if player:getMark("#ysch2__huangquan_showGeneral") ~= 0 then
                    player.general = player:getMark("#ysch2__huangquan_showGeneral")
                    room:broadcastProperty(player, "general")
                end
            end
        end
        if player:getMark("#ysch2__huangquan_showGeneral") ~= 0 then
            player.general = player:getMark("#ysch2__huangquan_showGeneral")
            room:broadcastProperty(player, "general")
        end
    end,
}
local canmeng_active = fk.CreateActiveSkill{
    name = "ysch2_canmeng_active",
    card_num = function (self)
        if self.interaction.data == "#ysch2_canmeng1" then
            return 1
        else
            return 2
        end
    end,
    target_num = function (self)
        if self.interaction.data == "#ysch2_canmeng1" then
            return 0
        else
            return 2
        end
    end,
    interaction = function(self)
        return UI.ComboBox {choices = {"#ysch2_canmeng1","#ysch2_canmeng2"}}
    end,
    card_filter = function(self, to_select, selected)
        if self.interaction.data == "#ysch2_canmeng1" then
            return #selected < 1
        else
            return #selected < 2
        end
    end,
    target_filter = function(self, to_select, selected, selected_cards)
        return self.interaction.data == "#ysch2_canmeng2" and Fk:currentRoom():getPlayerById(to_select):getMark("_ysch2_canmeng-phase") > 0
    end,
}
Fk:addSkill(canmeng_active)
canmeng:addRelatedSkill(canmeng_prohibit)
canmeng:addRelatedSkill(canmeng_use)
canmeng:addRelatedSkill(canmeng_effect)
huangquan:addSkill(canmeng)
Fk:loadTranslationTable{
    ["ysch2_nailuo"] = "奈落",
    ["ysch2_lunciskill"] = "<b>轮次技</b>：即“每轮限一次”的简称，指“于每个轮次中限发动一次”。<br>为标识技能发动频率的词语，不属于技能标签。",
    [":ysch2_nailuo"] = "<a href='ysch2_lunciskill'>轮次技</a>，当你使用无目标角色牌时，你可以摸至至多五张牌，其后等量张牌被使用时，场上角色技能失效至此牌结算完成。",
    ["#ysch2_nailuo-draw"] = "你可以发动 奈落，选择摸牌的数量",
    ["ysch2_nailuo_draw1"] = "摸至一张牌",
    ["ysch2_nailuo_draw2"] = "摸至两张牌",
    ["ysch2_nailuo_draw3"] = "摸至三张牌",
    ["ysch2_nailuo_draw4"] = "摸至四张牌",
    ["ysch2_nailuo_draw5"] = "摸至五张牌",
    ["@ysch2_nailuo"] = "奈落",
    ["@@ysch2_nailuo-turn"] = "奈落 技能失效",
    ["ysch2_canmeng"] = "残梦",
    ["ysch2_huiheskill"] = "<b>回合技</b>：即“每回合限一次”的简称，指“于每个回合中限发动一次”。<br>为标识技能发动频率的词语，不属于技能标签。",
    [":ysch2_canmeng"] = "<a href='ysch2_huiheskill'>回合技</a>，你可以视为使用一张【无懈可击】。结算前，你将一张牌置为底牌；结算中，你的牌失效；结算后，你须弃置一张牌或重铸两张牌并对两名本回合失去过牌的角色造成1点<font color='#b97eb4'>雷电伤害</font>。",
    ["#ysch2_canmeng"] = "残梦：将一张牌置为【无懈可击】的底牌",
    ["@@ysch2_canmeng"] = "残梦 卡牌失效",
    ["#ysch2_canmeng_effect"] = "残梦",
    ["ysch2_canmeng_active"] = "残梦",
    ["#ysch2_canmeng_active"] = "残梦：弃置一张牌，或重铸两张牌并对两名本回合失去过牌的角色造成1点雷电伤害",
    ["#ysch2_canmeng1"] = "弃牌",
    ["#ysch2_canmeng2"] = "重铸",

    ["$ysch2_nailuo1"] = "此生如朝露，身名俱灭。",
    ["$ysch2_nailuo2"] = "忘川无波澜，引渡徘徊。",
    ["$ysch2_canmeng1"] = "我为逝者哀哭……",
    ["$ysch2_canmeng2"] = "暮雨，终将落下。",
    ["$ysch2_canmeng3"] = "流淌吧…过往的刀光。",
    ["$ysch2_canmeng4"] = "暴雨将至。",
    ["~ysch2__huangquan"] = "尘埃…终归大地……",
}

local guanyu = General:new(extension, "ysch2__guanyu", "AOV", 4, 4, General.Male)--
Fk:loadTranslationTable{
    ["ysch2__guanyu"] = "关羽",
    ["#ysch2__guanyu"] = "一騎當千",
    ["designer:ysch2__guanyun"] = "铝",
    ["cv:ysch2__guanyu"] = "谢添天",
    ["illustrator:ysch2__guanyu"] = "王者荣耀",
}
local yiji = fk.CreateActiveSkill{
    name = "ysch2_yijidangqian",
    mute = true,
    prompt = "#ysch2_yijidangqian",
    card_num = 0,
    target_num = 0,
    card_filter = Util.FalseFunc,
    can_use = function (self, player, card, extra_data)
        if #player:getCardIds("h") == 0 or player:usedSkillTimes(self.name, Player.HistoryPhase) > 0 then return false end
        for _, id in ipairs(player:getCardIds("h")) do
            if Fk:getCardById(id):getMark("@@ShownCards-inhand") == 0 then
                return true
            end
        end
        return false
    end,
    on_cost = Util.FalseFunc,
    on_use = function(self, room, effect)
        local player = room:getPlayerById(effect.from)
        local room = player.room
        room:notifySkillInvoked(player,"ysch2_yijidangqian","special")
        player:broadcastSkillInvoke("ysch2_yijidangqian",math.random(1,2))
        for _, id in ipairs(player:getCardIds("h")) do
            room:setCardMark(Fk:getCardById(id), '@@ShownCards-inhand', 1)
            room:handleAddLoseSkills(player, "ysch_Al_shashan_use&")
        end
    end,
}
local dangqian = fk.CreateTriggerSkill{
    name = "#ysch2_yijidangqian-recastCard",
    mute = true,
    events = {fk.BeforeCardsMove},
    can_trigger = function (self, event, target, player, data)
        local turn_event = player.room.logic:getCurrentEvent():findParent(GameEvent.Turn)
        if not player:hasSkill("ysch2_yijidangqian") or (turn_event ~= nil and turn_event.data[1] == player) then return false end
        for _, move in ipairs(data) do
            if move.from == player.id and move.moveReason ~= fk.ReasonRecast then
                for _, info in ipairs(move.moveInfo) do
                    if Fk:getCardById(info.cardId):getMark("@@ShownCards-inhand") > 0 then
                        return true
                    end
                end
            end
        end
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        room:notifySkillInvoked(player,"ysch2_yijidangqian","drawcard")
        for _, move in ipairs(data) do
            for _, info in ipairs(move.moveInfo) do
                player:broadcastSkillInvoke("ysch2_yijidangqian",math.random(3,5))
                player.room:recastCard({info.cardId},player,self.name)
            end
            move.moveInfo = {}
        end
    end,

    refresh_events = {fk.AfterCardsMove},
    can_refresh = function (self, event, target, player, data)
        if player:hasSkill("ysch_Al_shashan_use&") then
            if #player:getCardIds("h") > 0 then
                for _, id in ipairs(player:getCardIds("h")) do
                    if Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0 or Fk:getCardById(id).name == "shashan" then
                        return false
                    end
                end
            end
            return true
        end
        return false
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        room:handleAddLoseSkills(player, "-ysch_Al_shashan_use&")
    end,
}
local yijidangqian = fk.CreateFilterSkill{
    name = "#ysch2_yijidangqian-view",
    card_filter = function(self, card, player)
        return player:hasSkill("ysch2_yijidangqian") and Fk:getCardById(card.id):getMark("@@ShownCards-inhand") > 0
    end,
    view_as = function(self, card)
        local c = Fk:cloneCard("shashan", card.suit, card.number)
        c.skillName = "ysch2_yijidangqian"
        return c
    end,
}
yiji:addRelatedSkill(dangqian)
yiji:addRelatedSkill(yijidangqian)
--yiji:addRelatedSkill(shashanUse)
guanyu:addSkill(yiji)
Fk:loadTranslationTable{
    ["ysch2_yijidangqian"] = "一骑当千",
    [":ysch2_yijidangqian"] = "出牌阶段限一次，你可以明置所有手牌。你的明置牌视为【杀/闪】，且于回合外失去时改为重铸。",
    ["#ysch2_yijidangqian"] = "发动 一骑当千，明置所有手牌",
    ["#ysch2_yijidangqian-recastCard"] = "一骑当千",

    ["$ysch2_yijidangqian1"] = "决定了内心的正道，便绝无动摇",
    ["$ysch2_yijidangqian2"] = "自己选择的路，再荒谬也要走完！",
    ["$ysch2_yijidangqian3"] = "一骑当千！",
    ["$ysch2_yijidangqian4"] = "单刀咆哮！",
    ["$ysch2_yijidangqian5"] = "血战到底！",
}

local maixiaowen = General:new(extension, "ysch2__maixiaowen", "delta", 3, 3, General.Female)--
Fk:loadTranslationTable{
    ["ysch2__maixiaowen"] = "麦晓雯",
    ["#ysch2__maixiaowen"] = "骇爪",
    ["designer:ysch2__maixiaowen"] = "铝",
    ["cv:ysch2__maixiaowen"] = "未知",
    ["illustrator:ysch2__maixiaowen"] = "三角洲行动",
}
local xinhaopoyi = fk.CreateActiveSkill{
    name = "ysch2_xinhaopoyi",
    card_num = 0,
    target_num = 0,
    prompt = function(self, card)
        return "#ysch2_xinhaopoyi-active"
    end,
    card_filter = Util.FalseFunc,
    can_use = function (self, player, card, extra_data)
        return player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 and
        table.find(Fk:currentRoom().alive_players, function(p) return player:inMyAttackRange(p) end)
    end,
    on_use = function(self, room, effect)
        local player = room:getPlayerById(effect.from)
        local max = 0
        local targets = table.filter(room:getOtherPlayers(player), function(p)
            if p:getHandcardNum() > max then
                max = p:getHandcardNum()
            end
            return player:inMyAttackRange(p) end)
        if #targets == 0 then return end
        room:doIndicate(player.id, table.map(targets, Util.IdMapper))
        local nums = {}
        for i = 0, max, 1 do
            table.insert(nums, tostring(i))
        end
        local answer = U.askForJointChoice(targets, nums, self.name, "#ysch2_xinhaopoyi-choice:"..player.id, true)
        local to,response_cards,bool = room:askForChooseCardsAndPlayers(player,1,1,table.map(targets, Util.IdMapper),1,1,'jink','#ysch2_xinhaopoyi-response',self.name,true,nil,nil)
        if bool then
            local t = room:getPlayerById(to[1])
            room:askForCardsChosen(player, t, 0, 0, {
                card_data = {
                  { "$Hand", t:getCardIds(Player.Hand) }
                }
            }, self.name, "#ysch2_xinhaopoyi-hand::"..to[1]..":"..answer[to[1]])
            room:responseCard({
                from = player.id,
                card = Fk:getCardById(response_cards[1]),
            })
            if #table.filter(t:getCardIds("h"), function(c) return Fk:getCardById(c).trueName == "jink" end) ~= tonumber(answer[to[1]]) then
                room:setPlayerMark(t, "@@ysch2_xinhaopoyi-turn", 1)
            end
        end
    end,
}
local xinhaopoyi_invalidity = fk.CreateInvaliditySkill {
    name = "#ysch2_xinhaopoyi_invalidity",
    invalidity_func = function(self, from, skill)
      return from:getMark("@@ysch2_xinhaopoyi-turn") > 0 and (skill:isPlayerSkill(from) or skill:isEquipmentSkill(from))
    end,
}
xinhaopoyi:addRelatedSkill(xinhaopoyi_invalidity)
maixiaowen:addSkill(xinhaopoyi)
local xunfeishanguang = fk.CreateTriggerSkill{
    name = "ysch2_xunfeishanguang",
    anim_type = "drawcard",
    events = {fk.AfterCardsMove},
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(self) then
        for _, move in ipairs(data) do
            if move.from == player.id then
                for _, info in ipairs(move.moveInfo) do
                    if info.fromArea == Player.Hand or info.fromArea == Player.Equip then
                        if Fk:getCardById(info.cardId).trueName == "jink" then
                            return player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
                        end
                    end
                end
            end
        end
        end
    end,
    on_cost = function (self, event, target, player, data)
        local targets = table.filter(player.room.alive_players, function (p) return not p:isNude() and player:inMyAttackRange(p) end)
        if #targets > 0 then
            local tos = player.room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1,
            "#ysch2_xunfeishanguang-choose", self.name, true)
            if #tos > 0 then
                self.cost_data = {tos = tos}
                return true
            end
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local to = room:getPlayerById(self.cost_data.tos[1])
        local cards = room:askForCardChosen(player, to, "he", self.name)
        room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonGive, self.name, nil, false, player.id)
    end,
}
maixiaowen:addSkill(xunfeishanguang)
Fk:loadTranslationTable{
    ["ysch2_xinhaopoyi"] = "信号破译",
    [":ysch2_xinhaopoyi"] = "出牌阶段限一次，你可以询问攻击范围内角色手牌中【闪】数；然后你可以观看其中一名角色的手牌并打出一张【闪】：若其撒谎，其本回合技能和装备失效。",
    ["#ysch2_xinhaopoyi-active"] = "信号破译：询问攻击范围内角色手牌中【闪】数，并可观看其中一名角色手牌验证，若其撒谎，其本回合技能和装备失效",
    ["#ysch2_xinhaopoyi-choice"] = "来自%src的信号破译：声明手牌中【闪】数",
    ["#ysch2_xinhaopoyi-response"] = "信号破译：你可以打出一张【闪】并观看一名角色的手牌验证之",
    ["#ysch2_xinhaopoyi-hand"] = "信号破译：观看%dest的手牌，其回答有%arg张【闪】",
    ["@@ysch2_xinhaopoyi-turn"] = "技能和装备失效",
    ["ysch2_xunfeishanguang"] = "巡飞闪光",
    [":ysch2_xunfeishanguang"] = "每回合限一次，当你失去一张【闪】后，你可以获得攻击范围内的角色一张牌。",
    ["#ysch2_xunfeishanguang-choose"] = "是否发动 巡飞闪光，获得攻击范围内的角色一张牌",
}

local MiSide = General:new(extension, "ysch2__MiSide", "Russia", 4, 4, General.Female)--
local MiSide2 = General:new(extension, "ysch2__MiSide2", "Russia", 4, 4, General.Female)--
MiSide2.total_hidden = true
Fk:loadTranslationTable{
    ["ysch2__MiSide"] = "米塔",
    ["ysch2__MiSide2"] = "米塔",
    ["#ysch2__MiSide"] = "Отдай лицемерие и прими истинное я",
    ["designer:ysch2__MiSide"] = "铝",
    ["cv:ysch2__MiSide"] = "未知",
    ["illustrator:ysch2__MiSide"] = "米塔MiSide",
}
local tianmixianjing = fk.CreateTriggerSkill{
    name = "ysch2_tianmixianjing",
    events = {fk.RoundStart, fk.AfterCardsMove},
    mute = true,
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(self) then
            if event == fk.RoundStart then
                return player:getMark(self.name) == 0
            else
                local num = #player.room.logic:getEventsOfScope(GameEvent.MoveCards, 4, function(e)
                    for _, move in ipairs(e.data) do
                        if move.to == player.id and move.toArea == Card.PlayerHand then
                            return true
                        end
                    end
                end, Player.HistoryTurn)
                if num > 3 or player:getMark(self.name) == 0 then return false end
                for _, move in ipairs(data) do
                    if move.to == player.id and move.toArea == Card.PlayerHand then
                      return true
                    end
                end
            end
        end
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        if event ~= fk.RoundStart then
            local tp = player.room:getPlayerById(player:getMark(self.name))
            local choices = {"ysch2_tianmixianjing_draw"}
            if ( #player:getCardIds("hej") > 0  or player:getMark("@@ysch2_daimashikong") ~= 0 ) and #tp:getCardIds("hej") > 0 then
                table.insert(choices,"ysch2_tianmixianjing_discard")
            end
            table.insert(choices,"Cancel")
            local prompt = "#ysch2_tianmixianjing-choice::"..player:getMark(self.name)
            if player:getMark("@@ysch2_daimashikong") ~= 0 then
                prompt = "#ysch2_tianmixianjing2-choice::"..player:getMark(self.name)
            end
            local choice = room:askForChoice(player, choices, self.name,
            prompt,false,{"ysch2_tianmixianjing_draw", "ysch2_tianmixianjing_discard", "Cancel"})
            if choice ~= "Cancel" then
                self.cost_data = choice
                return true
            else
                return false
            end
        else
            local targets = table.map(room:getOtherPlayers(player, false), Util.IdMapper)
            if #targets == 0 then return false end
            local to = room:askForChoosePlayers(player, targets, 1, 1, "#ysch2_tianmixianjing-choose", self.name, false, true)
            if #to > 0 then
                self.cost_data = to
                return true
            end
        end
    end,
    dynamic_desc = function(self, player)
        if player:getMark("@@ysch2_daimashikong") ~= 0 then
            return "ysch2_tianmixianjing_fix"
        else
            return ""
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        if event == fk.RoundStart then
            room:notifySkillInvoked(player, self.name, "special")
            local to = self.cost_data
            room:setPlayerMark(player, self.name, to[1])
            if player:getMark("@@ysch2_daimashikong") ~= 0 then
                player:broadcastSkillInvoke(self.name,6)
                room:setPlayerMark(room:getPlayerById(to[1]), "@@ysch2_tianmixianjing", 1)
            else
                player:broadcastSkillInvoke(self.name,1)
                room:setPlayerMark(room:getPlayerById(to[1]), "@ysch2_tianmixianjing", player.general)
            end
        else
            local tp = player.room:getPlayerById(player:getMark(self.name))
            if self.cost_data == "ysch2_tianmixianjing_draw" then
                room:notifySkillInvoked(player, self.name, "drawcard")
                tp:drawCards(1, self.name)
                if player:getMark("@@ysch2_daimashikong") == 0 then
                    room:setPlayerMark(tp, "@ysch2_tianmixianjing_true", 0)
                    room:setPlayerMark(tp, "@ysch2_tianmixianjing", player.general)
                    player:broadcastSkillInvoke(self.name,table.random({2,3}))
                else
                    player:broadcastSkillInvoke(self.name,table.random({7,8}))
                end
            else
                local card_data = {}
                if player:getMark("@@ysch2_daimashikong") == 0 then
                    room:setPlayerMark(tp, "@ysch2_tianmixianjing", 0)
                    room:setPlayerMark(tp, "@ysch2_tianmixianjing_true", player.general)
                    card_data = {{tp.general,{}},{"你",{}}}
                    player:broadcastSkillInvoke(self.name,table.random({4,5}))
                else
                    player:broadcastSkillInvoke(self.name,table.random({9,10}))
                end
                if tp:getHandcardNum() > 0 then
                    local handcards = {}
                    for _ = 1, tp:getHandcardNum() do
                        table.insert(handcards, -1) -- 手牌不可见
                    end
                    if player:getMark("@@ysch2_daimashikong") ~= 0 then
                        table.insert(card_data, {"$Hand_opposite", handcards})
                    else
                        table.insertTable(card_data[1][2], handcards)
                    end
                end
                local areas = { {"$Equip", Player.Equip}, {"$Judge", Player.Judge} }
                for _, v in ipairs(areas) do
                    local area = v[2]
                    if #tp.player_cards[area] > 0 then
                        if player:getMark("@@ysch2_daimashikong") ~= 0 then
                            table.insert(card_data, {v[1] .. "_opposite", tp:getCardIds(area)})
                        else
                            table.insertTable(card_data[1][2], tp:getCardIds(area))
                        end
                    end
                end
                table.insert(areas, 1, { "$Hand", Player.Hand})
                if player:getMark("@@ysch2_daimashikong") == 0 then
                    for _, v in ipairs(areas) do
                        local area = v[2]
                        if #player.player_cards[area] > 0 then
                            table.insertTable(card_data[2][2], player:getCardIds(area))
                        end
                    end
                end

                local ret = room:askForPoxi(player, "ysch2_tianmixianjing_poxi", card_data, nil, false)
                local new_ret = table.filter(ret, function(id) return id ~= -1 end)
                local hand_num = #ret - #new_ret
                if hand_num > 0 then
                    table.insertTable(new_ret, table.random(tp:getCardIds(Player.Hand), hand_num))
                end
                local moveInfos = {}
                local cards1 = {}
                for i = #new_ret, 1, -1 do
                    if room:getCardOwner(new_ret[i]) == player then
                        table.insert(cards1, new_ret[i])
                        table.remove(new_ret, i)
                    end
                end
                if #cards1 > 0 then
                    table.insert(moveInfos, {
                        from = player.id,
                        ids = cards1,
                        toArea = Card.DiscardPile,
                        moveReason = fk.ReasonDiscard,
                        proposer = player.id,
                        skillName = self.name,
                    })
                end
                if #new_ret > 0 then
                    table.insert(moveInfos, {
                        from = tp.id,
                        ids = new_ret,
                        toArea = Card.DiscardPile,
                        moveReason = fk.ReasonDiscard,
                        proposer = player.id,
                        skillName = self.name,
                    })
                end
                room:notifySkillInvoked(player, self.name, "control")
                room:moveCards(table.unpack(moveInfos))
            end
        end
    end,

    refresh_events = {fk.BuryVictim},
    can_refresh = function(self, event, target, player, data)
        return player:getMark(self.name) == target.id
    end,
    on_refresh = function(self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(player, self.name, 0)
        --room:setPlayerMark(target, "@ysch2_tianmixianjing", 0)
    end,
}
Fk:addPoxiMethod{
    name = "ysch2_tianmixianjing_poxi",
    card_filter = function(to_select, selected, data)
        for _, areas in ipairs(data) do
            if #table.filter(selected,function (id)
                return table.contains(areas[2],id)
            end)>0 and table.contains(areas[2],to_select) then
               return false 
            end
        end
        return #selected < #data
    end,
    feasible = function(selected, data)
      return data and #selected == #data
    end,
    prompt = function (data)
        if data and data[2] and data[2][1] == "你" then
            return "#ysch2_tianmixianjing-discardchoose"
        else
            return "#ysch2_tianmixianjing2-discardchoose"
        end
    end,
    default_choice = function (data)
        if not data then return {} end
        local cids = table.map(data,function (v)
            return v[2][1]
        end)
        return cids
    end,
}
MiSide:addSkill(tianmixianjing)
local daimashikong = fk.CreateTriggerSkill{
    name = "ysch2_daimashikong",
    frequency = Skill.Limited,
    mute = true,
    events = {fk.TurnEnd},
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0 and player:getMark("@@ysch2_daimashikong") == 0
    end,
    dynamic_desc = function(self, player)
        if player:getMark("@@ysch2_daimashikong") ~= 0  or math.random() > 0.6 then
            return "ysch2_daimashikong_fix"
        else
            return ""
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:notifySkillInvoked(player,self.name,"big")
        player:broadcastSkillInvoke(self.name,1)
        room:setPlayerMark(player, "@@ysch2_daimashikong", 1)
        room:handleAddLoseSkills(player,"ysch2_hewozaiyiqi",self.name)
        player.tag[self.name] = true
        player.tag["ysch2_tianmixianjing"] = player:getMark("ysch2_tianmixianjing")
        room:killPlayer({ who = player.id })
        --[[player._splayer:setDied(false)
        room:setPlayerRest(player, 1)
        player.dead = true
        table.removeOne(room.alive_players, player)
        room:broadcastProperty(player, "dead")]]--
    end,

    refresh_events = {fk.RoundStart,fk.BeforeGameOverJudge},
    can_refresh = function (self, event, target, player, data)
        return ( player.rest > 0 or event == fk.BeforeGameOverJudge ) and player.tag[self.name]
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        if event == fk.BeforeGameOverJudge then
            player._splayer:setDied(false)
            room:setPlayerRest(player, 1)
        else
            if player.general == "ysch2__MiSide" then
                player.general = "ysch2__MiSide2"
                room:broadcastProperty(player, "general")
            end
            player:broadcastSkillInvoke(self.name,2)
            player.tag[self.name] = nil
            room:setPlayerRest(player, 0)
            if player.dead then
                room:revivePlayer(player, false, "rest")
            end
            local x = player.maxHp - player.hp
            if x ~= 0 then
                room:changeHp(player, x, nil, self.name)
            end
            if 4 - player:getHandcardNum() > 0 then
                room:drawCards(player,4 - player:getHandcardNum())
            end
            room:setPlayerMark(player, "@@ysch2_daimashikong", 1)
            room:setPlayerMark(player, "ysch2_tianmixianjing", player.tag["ysch2_tianmixianjing"])
            player.tag["ysch2_tianmixianjing"] = nil
        end
    end,
}
daimashikong.permanent_skill = true
--daimashikong:addRelatedSkill(tianmixianjing)
MiSide:addSkill(daimashikong)
local hewozaiyiqi = fk.CreateActiveSkill{
    name = "ysch2_hewozaiyiqi",
    anim_type = "support",
    prompt = "#ysch2_hewozaiyiqi",
    min_target_num = 1,
    card_filter = Util.FalseFunc,
    mute = true,
    target_filter = function(self, to_select, selected, selected_cards, _, _, player)
        local c = Fk:cloneCard("ysch_Al__sincere_treat")
        c.skillName = self.name
        return c.skill:targetFilter(to_select, selected, selected_cards, c, nil, player) and
        not player:isProhibited(Fk:currentRoom():getPlayerById(to_select), c)
    end,
    on_use = function(self, room, effect)
        local player = room:getPlayerById(effect.from)
        local c = Fk:cloneCard("ysch_Al__sincere_treat")
        c.skillName = self.name
        local use = {
            from = player.id,
            tos = table.map(effect.tos, function (id) return {id} end),
            card = c,
            --extra_data = {ysch2_hewozaiyiqi_user = player.id},
        }
        room:notifySkillInvoked(player,self.name,"support")
        player:broadcastSkillInvoke(self.name,1)
        room:useCard(use)
        if player.dead then return end
        while #player:getCardIds(Player.Hand) > 0 and #table.filter(player:getCardIds(Player.Hand), function (id)
            return Fk:getCardById(id):getMark("@@ysch2_hewozaiyiqi-inarea-phase") > 0
        end) > 0 do
            local Cards = {}
            for _, id in ipairs(table.filter(player:getCardIds(Player.Hand), function (id)
                return Fk:getCardById(id):getMark("@@ysch2_hewozaiyiqi-inarea-phase") > 0
            end)) do
                local card = Fk:getCardById(id)
                if not player:prohibitUse(card) and player:canUse(card, {bypass_times = true})  and (card.type == Card.TypeBasic or card:isCommonTrick()) then
                    --[[if card.trueName == "slash" or table.filter(effect.tos, function (tp)
                        return card.skill and card.skill.targetFilter and (card.skill:targetFilter(tp, {}, {}, c, nil, player) or card.skill:targetFilter(tp, {}, {}, c, nil, room:getPlayerById(tp)))
                    end) then]]--
                    table.insertIfNeed(Cards, id)
                    --end
                end
            end
            local use = room:askForUseRealCard(player, Cards, self.name, "#ysch2_hewozaiyiqi-use", {exclusive_targets = effect.tos,bypass_times = true}, true, true)
            if use then
                player:broadcastSkillInvoke(self.name,2)
                local toss = {}
                for _,id in ipairs(use.tos) do
                    if table.contains(table.map(effect.tos, function (id) return {id} end),id) then
                        table.insert(toss,id)
                    end
                end
                if #toss == 0 then toss = table.map(effect.tos, function (id) return {id} end) end
                use.tos = toss
                room:useCard(use)
            else
                break
            end
        end
        for _, id in ipairs(table.filter(player:getCardIds(Player.Hand), function (id)
            return Fk:getCardById(id):getMark("@@ysch2_hewozaiyiqi-inarea-phase") > 0
        end)) do
            local card = Fk:getCardById(id)
            room:setCardMark(card, "@@ysch2_hewozaiyiqi-inarea-phase", 0)
        end
      end,
    can_use = function (self, player)
        return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
    end,
}
local hewozaiyiqi_delay = fk.CreateTriggerSkill{
    name = "#ysch2_hewozaiyiqi_delay",
    refresh_events = {fk.AfterCardsMove},
    can_refresh = function(self, event, target, player, data)
        local e = player.room.logic:getCurrentEvent():findParent(GameEvent.CardEffect)
        if e and player:hasSkill("ysch2_hewozaiyiqi") then
            local use = e.data[1]
            if table.contains(use.card.skillNames, "ysch2_hewozaiyiqi") then
                for _, move in ipairs(data) do
                    if move.toArea == Card.PlayerHand then
                        if move.to == player.id then
                            for _, info in ipairs(move.moveInfo) do
                                if table.contains(player:getCardIds("h"), info.cardId) then
                                    player.room:setCardMark(Fk:getCardById(info.cardId, true), "@@ysch2_hewozaiyiqi-inarea-phase", 1)
                                else
                                    player.room:setCardMark(Fk:getCardById(info.cardId, true), "@@ysch2_hewozaiyiqi-inarea-phase", 0)
                                end
                            end
                        else
                            for _, info in ipairs(move.moveInfo) do
                                if table.contains(player:getCardIds("h"), info.cardId) then
                                    player.room:setCardMark(Fk:getCardById(info.cardId, true), "@@ysch2_hewozaiyiqi-inarea-phase", 1)
                                else
                                    player.room:setCardMark(Fk:getCardById(info.cardId, true), "@@ysch2_hewozaiyiqi-inarea-phase", 0)
                                end
                            end
                        end
                    end
                end
            end
        end
    end,
}
local hewozaiyiqi_targetmod = fk.CreateTargetModSkill{
    name = "#ysch2_hewozaiyiqi_targetmod",
    bypass_distances = function(self, player, skill, card)
      return card and table.contains(card.skillNames, "ysch2_hewozaiyiqi")
    end,
}
hewozaiyiqi:addRelatedSkill(hewozaiyiqi_targetmod)
hewozaiyiqi:addRelatedSkill(hewozaiyiqi_delay)
MiSide:addRelatedSkill(hewozaiyiqi)
local MiSide_win = fk.CreateActiveSkill{ name = "ysch2__MiSide_win_audio" }
MiSide_win.package = extension
Fk:addSkill(MiSide_win)
local MiSide2_win = fk.CreateActiveSkill{ name = "ysch2__MiSide2_win_audio" }
MiSide2_win.package = extension
Fk:addSkill(MiSide2_win)
Fk:loadTranslationTable{
    ["ysch2_tianmixianjing"] = "甜蜜陷阱",
    [":ysch2_tianmixianjing"] = "轮次开始时，若场上无“甜蜜陷阱”角色，你须选择一名其他角色。每回合你前三次获得牌后，可令其摸一张牌，或弃置你与其区域内各一张牌。",
    [":ysch2_tianmixianjing_fix"] = "轮次开始时，若场上无“甜蜜陷阱”角色，你须选择一名其他角色。每回合你前三次获得牌后，可令其摸一张牌，或弃置其区域内各一张牌。",
    ["@ysch2_tianmixianjing"] = "甜蜜恋爱",
    ["@ysch2_tianmixianjing_true"] = "甜蜜陷阱",
    ["@@ysch2_tianmixianjing"] = "锟斤拷 烫烫烫",
    ["#ysch2_tianmixianjing-choose"] = "甜蜜陷阱：选择一名其他角色",
    ["#ysch2_tianmixianjing-choice"] = "甜蜜陷阱：令%dest摸一张牌，或弃置你与其区域内各一张牌",
    ["#ysch2_tianmixianjing2-choice"] = "甜蜜陷阱：令%dest摸一张牌，或弃置其区域内各一张牌",
    ["ysch2_tianmixianjing_draw"] = "摸牌",
    ["ysch2_tianmixianjing_discard"] = "弃牌",
    ["#ysch2_tianmixianjing-discardchoose"] = "甜蜜陷阱：弃置你和其区域内各一张牌",
    ["#ysch2_tianmixianjing2-discardchoose"] = "甜蜜陷阱：弃置其区域内各一张牌",
    ["ysch2_daimashikong"] = "代码失控",
    [":ysch2_daimashikong"] = "限定技，回合结束时，你可获得“和我在一起！”并删除“甜蜜陷阱”中的“你与”，然后杀死自己并休整至下轮开始时。",
    [":ysch2_daimashikong_fix"] = "闄愬畾鎶�锛屽洖鍚堢粨鏉熸椂锛屼綘鍙幏寰椻�滃拰鎴戝湪涓�璧凤紒鈥濆苟鍒犻櫎鈥滅敎铚滈櫡闃扁�濅腑鐨勨�滀綘涓庘�濓紝鐒跺悗鏉�姝昏嚜宸卞苟浼戞暣鑷充笅杞紑濮嬫椂銆�",
    ["@@ysch2_daimashikong"] = "浠ｇ爜澶辨帶",
    ["$ysch2_daimashikong"] = "Ты всем нравишься, все хотят быть с тобой, все хотят, чтобы тебя видели.",
    ["ysch2_hewozaiyiqi"] = "和我在一起！",
    [":ysch2_hewozaiyiqi"] = "出牌阶段限一次，你可视为使用一张无距离限制的【推心置腹】，然后对目标使用以此获得的任意张即时牌。",
    ["#ysch2_hewozaiyiqi"] = "和我在一起！：视为使用一张【推心置腹】，然后对目标使用以此获得的任意张即时牌",
    ["#ysch2_hewozaiyiqi-use"] = "和我在一起！：你可以对目标使用你以此获得的任意张即时牌",
    ["@@ysch2_hewozaiyiqi-inarea-phase"] = "和我在一起！",

    ["$ysch2_tianmixianjing1"] = "我相信，有了你，有了玩家的帮助，一定能成功的。",
    ["$ysch2_tianmixianjing2"] = "我是你在这里能找到的最友善的人了，亲爱的。",
    ["$ysch2_tianmixianjing3"] = "那我们现在来把事情捋捋清楚吧？",
    ["$ysch2_tianmixianjing4"] = "她是个杀人狂，我们得阻止她。",
    ["$ysch2_tianmixianjing5"] = "可能是一些故障，漏洞，异常...",
    ["$ysch2_daimashikong1"] = "我好像掉了什么东西，我马上回来...然后我们就可以前往另一个世界了...",
    ["$ysch2_daimashikong2"] = "你弄丢了什么东西吗？来啊，重新认识一下她吧！",

    ["$ysch2_tianmixianjing6"] = "但是，玩家，不管怎么说，我还是很喜欢你的！",
    ["$ysch2_tianmixianjing7"] = "我是说，你本可以留下来和我在一起的...",
    ["$ysch2_tianmixianjing8"] = "我们很快会再见的！",
    ["$ysch2_tianmixianjing9"] = "你为什么要逃跑？",
    ["$ysch2_tianmixianjing10"] = "你为什么要从我身边逃走？",
    ["$ysch2_hewozaiyiqi1"] = "我只是要你留下来，和我在一起。",
    ["$ysch2_hewozaiyiqi2"] = "你还是什么都不懂...哈哈哈！",

    ["~ysch2__MiSide"] = "我好像掉了什么东西，我马上回来...然后我们就可以前往另一个世界了",
    ["~ysch2__MiSide2"] = "为什么我永远成为不了真正的米塔？因为我的版本根本就从未存在过！",
    ["ysch2__MiSide_win_audio"] = "觉醒前胜利",
    ["$ysch2__MiSide_win_audio"] = "恭喜过关！",
    ["ysch2__MiSide2_win_audio"] = "觉醒后胜利",
    ["$ysch2__MiSide2_win_audio"] = "哈哈！我看到了什么？你脸上又出现了新表情？",
}

local kaer = General:new(extension, "ysch2__kaer", "west", 3, 3, General.Male)--
Fk:loadTranslationTable{
    ["ysch2__kaer"] = "卡尔",
    ["#ysch2__kaer"] = "祈求者",
    ["designer:ysch2__kaer"] = "铝&yyuaN",
    ["cv:ysch2__kaer"] = "未知",
    ["illustrator:ysch2__kaer"] = "Dato2",
}
local yuansuqihuan = fk.CreateActiveSkill{
    name = "ysch2_yuansuqihuan",
    mute = true,
    card_filter = Util.FalseFunc,
    target_num = 0,
    times = function(self)
        return Self.phase == Player.Play and 3 - Self:usedSkillTimes(self.name, Player.HistoryPhase) or -1
    end,
    interaction = function(self)
        return UI.ComboBox {choices = {"#ysch2_yuansuqihuan_ice","#ysch2_yuansuqihuan_thunder","#ysch2_yuansuqihuan_fire"}}
    end,
    on_use = function (self, room, effect)
        local player = room:getPlayerById(effect.from)
        local choice = self.interaction.data
        local marks = player:getMark("@ysch2_yuansuqihuan")
        if type(marks) ~= "table" then
            marks = {}
        end
        table.insert(marks, choice)
        if #marks > 3 then
            table.remove(marks,1)
        end
        switch(choice,{
        ["#ysch2_yuansuqihuan_ice"] = function()
            room:notifySkillInvoked(player,self.name,"defensive")
            --player:chat("拈极点寒霜，灌注")
        end,
        ["#ysch2_yuansuqihuan_thunder"] = function()
            room:notifySkillInvoked(player,self.name,"negative")
            --player:chat("引诸天之雷电，刻印")
        end,
        ["#ysch2_yuansuqihuan_fire"] = function()
            room:notifySkillInvoked(player,self.name,"offensive")
            --player:chat("取地狱之火，炼制")
        end,
        })
        player.room:sendLog({type = "#ysch2_yuansuqihuan-msg",from = player.id,arg = choice})
        room:setPlayerMark(player, "@ysch2_yuansuqihuan", marks)
        if #marks >= 3 then
            local Q,W,E = "#ysch2_yuansuqihuan_ice","#ysch2_yuansuqihuan_thunder","#ysch2_yuansuqihuan_fire"
            local skill = nil
            function countElementInTable(t, element)
                local count = 0
                for _, value in pairs(t) do
                    if value == element then
                        count = count + 1
                    end
                end
                return count
            end
            local Qs,Ws,Es = countElementInTable(marks,Q),countElementInTable(marks,W),countElementInTable(marks,E)
            switch(Qs,{
                [0] = function ()
                    switch(Ws,{
                    [0] = function ()
                        skill = "ysch2_yuansuqihuan_EEE"
                    end,
                    [1] = function ()
                        skill = "ysch2_yuansuqihuan_WEE"
                    end,
                    [2] = function ()
                        skill = "ysch2_yuansuqihuan_WWE"
                    end,
                    [3] = function ()
                        skill = "ysch2_yuansuqihuan_WWW"
                    end,
                    })
                end,
                [1] = function ()
                    switch(Ws,{
                    [0] = function ()
                        skill = "ysch2_yuansuqihuan_EEQ"
                    end,
                    [1] = function ()
                        skill = "ysch2_yuansuqihuan_EQW"
                    end,
                    [2] = function ()
                        skill = "ysch2_yuansuqihuan_QWW"
                    end,
                    })
                end,
                [2] = function ()
                    switch(Ws,{
                    [0] = function ()
                        skill = "ysch2_yuansuqihuan_EQQ"
                    end,
                    [1] = function ()
                        skill = "ysch2_yuansuqihuan_QQW"
                    end,
                    })
                end,
                [3] = function ()
                    skill = "ysch2_yuansuqihuan_QQQ"
                end,
            })
            if skill ~= nil then
                local result = room:askForCustomDialog(player, self.name,
                    "packages/ysch_Al/qml/ChooseSkillBox.qml", {
                    {skill}, 1, 1, "#ysch2_yuansuqihuan-choice"
                })
                --local bool = room:askForChooseKingdom(player, {skill,"Cancel"}, self.name, "#ysch2_yuansuqihuan-choice",true)
                if result ~= "" then
                    local randomN = math.random(1,2)
                    player:chat(Util.TranslateMapper("$"..skill..randomN))
                    player:broadcastSkillInvoke(skill,randomN)

                    local skills = player:getTableMark("ysch2_yuansuqihuan_skills")
                    if type(skills) ~= "table" then
                        skills = {}
                    end
                    if player:hasSkill(skill) then
                        table.removeOne(skills,skill)
                    end
                    table.insert(skills,skill)
                    if #skills > 2 then
                        if player:hasSkill(skills[1],true) then
                            room:handleAddLoseSkills(player,"-"..skills[1],self.name)
                        end
                        table.remove(skills,1)
                    end

                    room:handleAddLoseSkills(player,skill,self.name)
                    room:setPlayerMark(player, "@ysch2_yuansuqihuan", 0)

                    local realNames = table.map(skills, Util.TranslateMapper)
                    room:setPlayerMark(player, "ysch2_yuansuqihuan_skills", skills)
                    if #realNames > 0 then
                        room:setPlayerMark(player, "@ysch2_yuansuqihuan_skills1", "<font color='burlywood'>"..realNames[1].."</font>")
                    end
                    if #realNames > 1 then
                        room:setPlayerMark(player, "@ysch2_yuansuqihuan_skills2", "<font color='burlywood'>"..realNames[2].."</font>")
                    end
                    --room:setPlayerMark(player, "@ysch2_yuansuqihuan_skills", "<font color='burlywood'>" .. table.concat(realNames, " ") .. "</font>")
                end
            end
        end
    end,
    can_use = function (self, player)
        return player:usedSkillTimes(self.name, Player.HistoryPhase) < 3
    end,
}
local yuansuqihuan_use = fk.CreateTriggerSkill{
    name = "#ysch2_yuansuqihuan",
    mute = true,
    refresh_events = {fk.AfterSkillEffect},
    can_refresh = function(self, _, target, player, data)
        if target == player and player:hasSkill("ysch2_yuansuqihuan")  and #player:getTableMark("ysch2_yuansuqihuan_skills")~=0 and data and data.name and data.name~=nil then
            for _, skn in ipairs(player:getTableMark("ysch2_yuansuqihuan_skills")) do
                    if  data.name == skn then
                        return true
                    else
                        local skillx = Fk.skills[skn]
                        if skillx and skillx.related_skills and skillx.related_skills~=nil and #skillx.related_skills>0 then
                            for _, sk in ipairs(skillx.related_skills) do
                                if sk.name and sk.name == data.name or (sk == data) then
                                    return true
                                end
                        end
                    end
                end
            end
        end
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        local result,_ = room:askForUseActiveSkill(player,"ysch2_yuansuqihuan","#ysch2_yuansuqihuan_prompt",true)
    end
}
yuansuqihuan:addRelatedSkill(yuansuqihuan_use)
kaer:addSkill(yuansuqihuan)
local QQQ = fk.CreateTriggerSkill{
    name = "ysch2_yuansuqihuan_QQQ",
    anim_type = "control",
    events = {fk.TargetSpecified},
    can_trigger = function(self, event, target, player, data)
        if target == player and data.card and player:hasSkill(self) and data.card.trueName == "slash" then
            local to = player.room:getPlayerById(data.to)
            return not to.dead and to.hp > 0 and not to:isNude()
        end
    end,
    on_cost = function(self, event, target, player, data)
        if player.room:askForSkillInvoke(player, self.name, nil, "#ysch2_yuansuqihuan_QQQ::"..data.to) then
            self.cost_data = {tos = {data.to}}
            data.extra_data = data.extra_data or {}
            data.extra_data.ysch2_yuansuqihuan_QQQ = data.extra_data.ysch2_yuansuqihuan_QQQ or {}
            table.insert(data.extra_data.ysch2_yuansuqihuan_QQQ,data.to)
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local to = room:getPlayerById(data.to)
        local cards = room:askForCardsChosen(player, to, math.min(2,#to:getCardIds('he')), math.min(2,#to:getCardIds('he')), "he", self.name)
        room:throwCard(cards, self.name, to, player)
        local e = room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
      end,

    refresh_events = {fk.CardUseFinished},
    can_refresh = function (self, event, target, player, data)
        if target == player and data.damageDealt and data.extra_data and data.extra_data.ysch2_yuansuqihuan_QQQ and #data.extra_data.ysch2_yuansuqihuan_QQQ > 0 then
            return true
        end
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        for _, pid in ipairs(data.extra_data.ysch2_yuansuqihuan_QQQ) do
            local p = room:getPlayerById(pid)
            if not p.dead then
                p:drawCards(1, self.name)
            end
        end
    end,
}
--Fk:addSkill(QQQ)
kaer:addRelatedSkill(QQQ)
local QQW = fk.CreateTriggerSkill{
    name = "ysch2_yuansuqihuan_QQW",
    anim_type = "defensive",
    events = {fk.DamageInflicted},
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(self) and target == player
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local card = room:askForDiscard(player, 1, 1, true, self.name, true, ".", "#ysch2_yuansuqihuan_QQW")
        if #card == 0 then
            card = room:drawCards(player, 1, self.name)
            player:showCards(card)
        end

        local no_used_type = {Card.TypeBasic,Card.TypeEquip,Card.TypeTrick}
        player.room.logic:getEventsOfScope(GameEvent.UseCard, 999, function(e)
            local use = e.data[1]
            table.removeOne(no_used_type, use.card.type)
        end, Player.HistoryTurn)
        local bool = false
        for _, id in ipairs(card) do
            local c = Fk:getCardById(id)
            if table.contains(no_used_type,c.type) then
                bool = true
                break
            end
        end
        if bool then
            return true
        end
    end,
}
--Fk:addSkill(QQW)
kaer:addRelatedSkill(QQW)
local QWW = fk.CreateTriggerSkill{
    name = "ysch2_yuansuqihuan_QWW",
    anim_type = "negative",
    events = {fk.AfterCardsMove},
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(self) then
            local ids = {}
            for _, move in ipairs(data) do
                if move.from == player.id and move.moveReason == fk.ReasonDiscard then
                    for _, info in ipairs(move.moveInfo) do
                        if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
                            table.insert(ids, info.cardId)
                        end
                    end
                end
            end
            if #ids > 0 then
                self.cost_data = {num = #ids}
                return true
            end
        end
    end,
    on_cost = function (self, event, target, player, data)
        local tos = player.room:askForChoosePlayers(player, table.map(player.room.alive_players, Util.IdMapper), 1, 1,
        "#ysch2_yuansuqihuan_QWW", self.name, true)
        if #tos > 0 then
            self.cost_data.tos = tos
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local to = room:getPlayerById(self.cost_data.tos[1])
        local card = room:askForDiscard(to, self.cost_data.num, self.cost_data.num, true, self.name, true, ".", "#ysch2_yuansuqihuan_QWW-choose:::"..self.cost_data.num)
        if #card == 0 then
            to:turnOver()
        end
    end,
}
--Fk:addSkill(QWW)
kaer:addRelatedSkill(QWW)
local WWW = fk.CreateActiveSkill{
    name = "ysch2_yuansuqihuan_WWW",
    anim_type = "special",
    card_num = 1,
    target_num = 1,
    card_filter = function (self, to_select, selected)
        return #selected == 0 and Fk:getCardById(to_select).color == Card.Black
    end,
    target_filter = Util.TrueFunc,
    on_use = function(self, room, use)
        local player = room:getPlayerById(use.from)
        local c = Fk:cloneCard("lightning")
        c:addSubcards(use.cards)
        c.skillName = self.name
        room:useCard{
            from = use.from,
            tos = table.map(use.tos, function (id) return {id} end),
            card = c,
        }
    end,
}
--Fk:addSkill(WWW)
kaer:addRelatedSkill(WWW)
local WWE = fk.CreateTriggerSkill{
    name = "ysch2_yuansuqihuan_WWE",
    anim_type = "drawcard",
    events = {fk.BeforeDrawCard},
    can_trigger = function(self, event, target, player, data)
        local events = player.room.logic:getEventsOfScope(GameEvent.MoveCards, 2, function(e)
            local data = e.data
            for _, move in ipairs(data) do
                if move.to == player.id and move.moveReason == fk.ReasonDraw then
                    return true
                end
            end
            return false
        end, Player.HistoryTurn)
        return player:hasSkill(self) and target == player and #events == 0
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        data.num = 4
        room.logic:getCurrentEvent().parent:addCleaner(function ()
            room:askForDiscard(player, 2, 2, true, self.name, false, ".")
        end)
    end,
}
--Fk:addSkill(WWE)
kaer:addRelatedSkill(WWE)
local WEE = fk.CreateTriggerSkill{
    name = "ysch2_yuansuqihuan_WEE",
    anim_type = "offensive",
    events = {fk.CardUseFinished},
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(self) and U.IsUsingHandcard(player, data) and player:usedSkillTimes(self.name, Player.HistoryTurn) < 1
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local success, dat = room:askForUseActiveSkill(player, "ysch2_yuansuqihuan_WEE_viewas", "#ysch2_yuansuqihuan_WEE", true)
        if success then
            self.cost_data = dat
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local card = Fk.skills["ysch2_yuansuqihuan_WEE_viewas"]:viewAs(self.cost_data.cards)
        room:useCard{
            from = player.id,
            tos = table.map(self.cost_data.targets, function(id) return {id} end),
            card = card,
            extraUse = true,
        }
    end,
}
local WEE_viewas = fk.CreateViewAsSkill{
    name = "ysch2_yuansuqihuan_WEE_viewas",
    pattern = "fire__slash",
    card_filter = Util.FalseFunc,
    view_as = function(self, cards)
        local card = Fk:cloneCard("fire__slash")
        card.skillName = "ysch2_yuansuqihuan_WEE"
        return card
    end,
}
local WEE_targetmod = fk.CreateTargetModSkill{
    name = "#ysch2_yuansuqihuan_WEE_targetmod",
    bypass_times = function(self, player, skill, scope, card)
      return card and table.contains(card.skillNames, "ysch2_yuansuqihuan_WEE")
    end,
}
Fk:addSkill(WEE_viewas)
WEE:addRelatedSkill(WEE_targetmod)
--Fk:addSkill(WEE)
kaer:addRelatedSkill(WEE)
local EEE = fk.CreateActiveSkill{
    name = "ysch2_yuansuqihuan_EEE",
    anim_type = "offensive",
    card_num = 0,
    target_num = 1,
    prompt = "#ysch2_yuansuqihuan_EEE",
    can_use = function(self, player)
        return not player:prohibitUse(Fk:cloneCard("fire_attack")) and player:usedSkillTimes(self.name, Player.HistoryPhase) < 1
    end,
    card_filter = Util.FalseFunc,
    target_filter = function(self, to_select, selected, selected_cards)
        local target = Fk:currentRoom():getPlayerById(to_select)
        return #selected == 0 and not target:isKongcheng() and not Self:isProhibited(target, Fk:cloneCard("fire_attack"))
    end,
    on_use = function(self, room, effect)
        local player = room:getPlayerById(effect.from)
        local target = room:getPlayerById(effect.tos[1])
        local use = room:useVirtualCard("fire_attack", nil, player, target, self.name)
        while use ~= nil and use.damageDealt do
            target = room:getPlayerById(target:getNextAlive().id)
            use = room:useVirtualCard("fire_attack", nil, player, target, self.name)
        end
    end,
}
--Fk:addSkill(EEE)
kaer:addRelatedSkill(EEE)
local EEQ = fk.CreateTriggerSkill{
    name = "ysch2_yuansuqihuan_EEQ",
    anim_type = "masochism",
    events = {fk.Damaged},
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and data.damageType == fk.FireDamage
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        room:drawCards(player, 1, self.name)
    end,
}
--Fk:addSkill(EEQ)
kaer:addRelatedSkill(EEQ)
local EQQ = fk.CreateTriggerSkill{
    name = "ysch2_yuansuqihuan_EQQ",
    anim_type = "support",
    on_cost = Util.TrueFunc,
    events = {fk.DamageInflicted},
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(self) and target == player and data.from and (data.from.id == player:getNextAlive().id or data.from.id == player:getLastAlive().id) and player:usedSkillTimes(self.name, Player.HistoryRound) < 1
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        if player:isWounded() then
            room:recover({
                who = player,
                num = 1,
                recoverBy = player,
                skillName = self.name,
            })
        end
        return true
    end,
}
--Fk:addSkill(EQQ)
kaer:addRelatedSkill(EQQ)
local EQW = fk.CreateActiveSkill{
    name = "ysch2_yuansuqihuan_EQW",
    anim_type = "big",
    card_num = 3,
    target_num = 0,
    can_use = function(self, player)
        return table.find(Fk:currentRoom().alive_players, function (p)
            return #p:getCardIds("e") > 0
        end)
    end,
    on_use = function (self, room, effect)
        local player = room:getPlayerById(effect.from)
        local tps = {player.id}
        room:throwCard(effect.cards, self.name, player, player)
        for _, p in ipairs(room:getAlivePlayers()) do
            if not p.dead and #p:getCardIds("e") > 0 then
                if not table.contains(tps,p.id) then
                    table.insert(tps,p.id)
                end
                p:throwAllCards("e", self.name)
            end
        end
        if #tps > 0 then
            room:drawCards(player, #tps, self.name)
        end
    end,
}
--Fk:addSkill(EQW)
kaer:addRelatedSkill(EQW)
Fk:loadTranslationTable{
    ["ysch2_yuansuqihuan"] = "元素祈唤",
    [":ysch2_yuansuqihuan"] = "出牌阶段限三次，或当你发动<a href='ysch2_yuansuqihuan-href'>元素融合技能</a>后，你可以获得一枚<font color='#78cadf'>冰</font>/<font color='#b97eb4'>雷</font>/<font color='#d2781e'>火</font>属性法球，然后你可以消耗3枚法球获得一个对应<a href='ysch2_yuansuqihuan-href'>元素融合技能</a>。（法球和技能上限分别为3和2，超出失去最先获得的）",
    ["ysch2_yuansuqihuan-href"] = "<b>急速冷却</b>(<font color='#78cadf'>冰冰冰</font>)：你使用【杀】指定目标后，可以弃置目标两张牌，若此牌造成伤害，其摸一张牌。"..
    "<br><b>幽灵漫步</b>(<font color='#78cadf'>冰冰</font><font color='#b97eb4'>雷</font>)：你受到伤害时，可以摸或弃一张牌，若含本回合未使用过的类别，防止之。"..
    "<br><b>强袭飓风</b>(<font color='#78cadf'>冰</font><font color='#b97eb4'>雷雷</font>)：你的牌被弃置时，可以令一名角色弃置等量张牌或翻面。"..
    "<br><b>电磁脉冲</b>(<font color='#b97eb4'>雷雷雷</font>)：你可以将一张黑色牌当【闪电】对任意角色使用，此牌使用时无判定区内数量限制。"..
    "<br><b>灵动迅捷</b>(<font color='#b97eb4'>雷雷</font><font color='#d2781e'>火</font>)：每回合你首次摸牌时，可改为摸四张牌并弃置两张牌。"..
    "<br><b>混沌陨石</b>(<font color='#b97eb4'>雷</font><font color='#d2781e'>火火</font>)：每回合限一次，你使用手牌结算完成后，可视为使用一张火【杀】。"..
    "<br><b>阳炎冲击</b>(<font color='#d2781e'>火火火</font>)：出牌阶段限一次，你可以视为使用【火攻】，若造成伤害，对目标下家重复此流程。"..
    "<br><b>熔炉精灵</b>(<font color='#d2781e'>火火</font><font color='#78cadf'>冰</font>)：有角色受到火焰伤害后，你摸一张牌。"..
    "<br><b>寒冰之墙</b>(<font color='#d2781e'>火</font><font color='#78cadf'>冰冰</font>)：每轮限一次，相邻角色对你造成伤害时，防止并回复1点体力。"..
    "<br><b>超震声波</b>(<font color='#d2781e'>火</font><font color='#78cadf'>冰</font><font color='#b97eb4'>雷</font>)：出牌阶段，你可以弃置三张牌和场上所有装备牌，然后你摸因此失去牌的角色数张牌。",
    ["#ysch2_yuansuqihuan_prompt"] = "元素祈唤：你可以获得一枚元素属性法球",
    ["#ysch2_yuansuqihuan-msg"] = "%from获得了一枚%arg属性法球",
    ["@ysch2_yuansuqihuan"] = "",
    ["@ysch2_yuansuqihuan_skills1"] = "",
    ["@ysch2_yuansuqihuan_skills2"] = "",
    ["#ysch2_yuansuqihuan_ice"] = "<font color='#78cadf'>冰</font>",
    ["#ysch2_yuansuqihuan_thunder"] = "<font color='#b97eb4'>雷</font>",
    ["#ysch2_yuansuqihuan_fire"] = "<font color='#d2781e'>火</font>",
    ["#ysch2_yuansuqihuan-choice"] = "元素祈唤<br>是否消耗所有法球，获得一个元素融合技能",

    ["ysch2_yuansuqihuan_QQQ"] = "急速冷却",
    [":ysch2_yuansuqihuan_QQQ"] = "你使用【杀】指定目标后，可以弃置目标两张牌，若此牌造成伤害，其摸一张牌。",
    ["#ysch2_yuansuqihuan_QQQ"] = "急速冷却：你可以弃置 %dest 两张牌，若此【杀】造成伤害，其摸一张牌",
    ["ysch2_yuansuqihuan_QQW"] = "幽灵漫步",
    [":ysch2_yuansuqihuan_QQW"] = "你受到伤害时，可以摸或弃一张牌，若含本回合未使用过的类别，防止之。",
    ["#ysch2_yuansuqihuan_QQW"] = "幽灵漫步：你可选择一张牌弃置，或点取消则摸一张牌",
    ["ysch2_yuansuqihuan_QWW"] = "强袭飓风",
    [":ysch2_yuansuqihuan_QWW"] = "你的牌被弃置时，可以令一名角色弃置等量张牌或翻面。",
    ["#ysch2_yuansuqihuan_QWW"] = "强袭飓风：令一名角色弃置等量张牌或翻面",
    ["#ysch2_yuansuqihuan_QWW-choose"] = "强袭飓风：弃置%arg张牌或翻面",
    ["ysch2_yuansuqihuan_WWW"] = "电磁脉冲",
    [":ysch2_yuansuqihuan_WWW"] = "你可以将一张黑色牌当【闪电】对任意角色使用，此牌使用时无判定区内数量限制。",
    ["ysch2_yuansuqihuan_WWE"] = "灵动迅捷",
    [":ysch2_yuansuqihuan_WWE"] = "每回合你首次摸牌时，可改为摸四张牌并弃置两张牌。",
    ["ysch2_yuansuqihuan_WEE"] = "混沌陨石",
    [":ysch2_yuansuqihuan_WEE"] = "每回合限一次，你使用手牌结算完成后，可视为使用一张火【杀】。",
    ["#ysch2_yuansuqihuan_WEE"] = "混沌陨石：你可以视为使用一张火【杀】",
    ["ysch2_yuansuqihuan_WEE_viewas"] = "混沌陨石",
    ["ysch2_yuansuqihuan_EEE"] = "阳炎冲击",
    [":ysch2_yuansuqihuan_EEE"] = "出牌阶段限一次，你可以视为使用【火攻】，若造成伤害，对目标下家重复此流程。",
    ["#ysch2_yuansuqihuan_EEE"] = "阳炎冲击：你可以视为使用【火攻】",
    ["ysch2_yuansuqihuan_EEQ"] = "熔炉精灵",
    [":ysch2_yuansuqihuan_EEQ"] = "有角色受到火焰伤害后，你摸一张牌。",
    ["ysch2_yuansuqihuan_EQQ"] = "寒冰之墙",
    [":ysch2_yuansuqihuan_EQQ"] = "每轮限一次，相邻角色对你造成伤害时，防止并回复1点体力。",
    ["ysch2_yuansuqihuan_EQW"] = "超震声波",
    [":ysch2_yuansuqihuan_EQW"] = "出牌阶段，你可以弃置三张牌和场上所有装备牌，然后你摸因此失去牌的角色数张牌。",

    ["$ysch2_yuansuqihuan_QQQ1"] = "三重玄冰",
    ["$ysch2_yuansuqihuan_QQQ2"] = "赛特昂的无尽战栗",
    ["$ysch2_yuansuqihuan_QQW1"] = "一重霹雳，双重寒冰",
    ["$ysch2_yuansuqihuan_QQW2"] = "米瑞特之阻碍",
    ["$ysch2_yuansuqihuan_QWW1"] = "一重寒冰，双重霹雳",
    ["$ysch2_yuansuqihuan_QWW2"] = "托纳鲁斯之爪",
    ["$ysch2_yuansuqihuan_WWW1"] = "三重霹雳",
    ["$ysch2_yuansuqihuan_WWW2"] = "恩多利昂的恶之混动",
    ["$ysch2_yuansuqihuan_WWE1"] = "一重烈火，双重霹雳",
    ["$ysch2_yuansuqihuan_WWE2"] = "盖斯特的猛战号令",
    ["$ysch2_yuansuqihuan_WEE1"] = "一重霹雳，双重烈火",
    ["$ysch2_yuansuqihuan_WEE2"] = "塔拉克的天坠之火",
    ["$ysch2_yuansuqihuan_EEE1"] = "三重烈火",
    ["$ysch2_yuansuqihuan_EEE2"] = "哈雷克之火葬魔咒",
    ["$ysch2_yuansuqihuan_EEQ1"] = "一重寒冰，双重烈火",
    ["$ysch2_yuansuqihuan_EEQ2"] = "卡尔维因的至邪产物",
    ["$ysch2_yuansuqihuan_EQQ1"] = "一重烈火，双重寒冰",
    ["$ysch2_yuansuqihuan_EQQ2"] = "科瑞克斯的杀戮之墙",
    ["$ysch2_yuansuqihuan_EQW1"] = "寒冰，霹雳，烈火",
    ["$ysch2_yuansuqihuan_EQW2"] = "布鲁冯特之无力声波",
}
local Surtr = General:new(extension, "ysch2__Surtr", "shu", 4, 4, General.Female)--
Fk:loadTranslationTable{
    ["ysch2__Surtr"] = "史尔特尔",
    ["#ysch2__Surtr"] = "黄昏焰剑",
    ["designer:ysch2__Surtr"] = "铝",
    ["cv:ysch2__Surtr"] = "未知",
    ["illustrator:ysch2__Surtr"] = "明日方舟",
}
local ronghun = fk.CreateActiveSkill{
    name = "ysch2_ronghun",
    anim_type = "offensive",
    interaction = function(self)
        local choices, all_choices = {}, {"fire_attack", "duel"}
        for _, v in ipairs(all_choices) do
            if not Self:prohibitUse(Fk:cloneCard(v)) then
                table.insert(choices,v)
            end
        end
        return U.CardNameBox {choices = choices, all_choices = all_choices}
    end,
    card_num = 0,
    target_num = 1,
    prompt = function (self)
        if self.interaction.data == "fire_attack" then
            return "熔魂：视为使用【火攻】与之展示牌"
        else
            return "熔魂：视为使用【决斗】与之打出牌"
        end
    end,
    can_use = function(self, player)
        return (not player:prohibitUse(Fk:cloneCard("fire_attack")) or not player:prohibitUse(Fk:cloneCard("duel"))) and player:usedSkillTimes(self.name, Player.HistoryPhase) < 1
    end,
    card_filter = Util.FalseFunc,
    target_filter = function(self, to_select, selected, selected_cards)
        local target = Fk:currentRoom():getPlayerById(to_select)
        return #selected == 0 and not Self:isProhibited(target, Fk:cloneCard(self.interaction.data)) and (self.interaction.data ~= "fire_attack" or not target:isKongcheng())
    end,
    on_use = function(self, room, effect)
        local player = room:getPlayerById(effect.from)
        local target = room:getPlayerById(effect.tos[1])
        local use = room:useVirtualCard(self.interaction.data, nil, player, target, self.name)
        if use ~= nil then
            local cards = {}
            if use.extra_data and use.extra_data.ysch2_ronghun then
                for _, info in ipairs(use.extra_data.ysch2_ronghun) do
                    table.insertIfNeed(cards, info[2])
                end
            end
            while #cards > 0 and not player.dead do
                --room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, true, player.id)
                local useR = U.askForUseRealCard(room, player, cards, nil, self.name, "#ysch2_ronghun-use",
                    {
                    expand_pile = cards,
                    bypass_times = true,
                }, true, true)
                if useR then
                    table.removeOne(cards, useR.card.id)
                    local cardR = Fk:cloneCard(useR.card.name,useR.card.suit,useR.card.number)
                    cardR.skillName = "ysch2_ronghun_trigger"
                    useR = {
                        card = cardR,
                        from = player.id,
                        tos = useR.tos,
                        extraUse = true,
                    }
                    room:useCard(useR)
                else
                    return
                end
            end
        end
    end,
}
local ronghun_fireAttackSkill = fk.CreateActiveSkill{
    name = "#ysch2_ronghun_fire_attack_skill",
    mute = true,
    prompt = "#fire_attack_skill",
    can_use = Util.CanUse,
    target_num = 1,
    mod_target_filter = function(_, to_select, _, _, _, _)
        local to = Fk:currentRoom():getPlayerById(to_select)
        return not to:isKongcheng()
    end,
    target_filter = Util.TargetFilter,
    on_effect = function(self, room, cardEffectEvent)
        local from = room:getPlayerById(cardEffectEvent.from)
        local to = room:getPlayerById(cardEffectEvent.to)
        if to:isKongcheng() then return end

        local showCard = room:askForCard(to, 1, 1, false, "fire_attack_skill", false, ".|.|.|hand", "#fire_attack-show:" .. from.id)[1]
        local use_event = room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
        if use_event then
            local use = use_event.data[1]
            use.extra_data = use.extra_data or {}
            use.extra_data.ysch2_ronghun = use.extra_data.ysch2_ronghun or {}
            table.insertIfNeed(use.extra_data.ysch2_ronghun, {to.id, showCard})
        end
        to:showCards(showCard)

        showCard = Fk:getCardById(showCard)
        local cards = room:askForDiscard(from, 1, 1, false, "fire_attack_skill", true,
        ".|.|" .. showCard:getSuitString(), "#fire_attack-discard:" .. to.id .. "::" .. showCard:getSuitString())
        if #cards > 0 then
        room:damage({
            from = from,
            to = to,
            card = cardEffectEvent.card,
            damage = 1,
            damageType = fk.FireDamage,
            skillName = "fire_attack_skill"
        })
        end
    end,
}
local ronghun_duelSkill = fk.CreateActiveSkill{
    name = "#ysch2_ronghun_duel_skill",
    mute = true,
    prompt = "#duel_skill",
    can_use = Util.CanUse,
    mod_target_filter = function(self, to_select, selected, player, card)
        return to_select ~= player.id
    end,
    target_filter = Util.TargetFilter,
    target_num = 1,
    on_effect = function(self, room, effect)
        local to = room:getPlayerById(effect.to)
        local from = room:getPlayerById(effect.from)
        local responsers = { to, from }
        local currentTurn = 1
        local currentResponser = to
        local use_event = room.logic:getCurrentEvent():findParent(GameEvent.UseCard)

        while currentResponser:isAlive() do
        local loopTimes = 1
        if effect.fixedResponseTimes then
            local canFix = currentResponser == to
            if effect.fixedAddTimesResponsors then
            canFix = table.contains(effect.fixedAddTimesResponsors, currentResponser.id)
            end

            if canFix then
            if type(effect.fixedResponseTimes) == 'table' then
                loopTimes = effect.fixedResponseTimes["slash"] or 1
            elseif type(effect.fixedResponseTimes) == 'number' then
                loopTimes = effect.fixedResponseTimes
            end
            end
        end

        local cardResponded
        for i = 1, loopTimes do
            cardResponded = room:askForResponse(currentResponser, 'slash', nil, nil, true, nil, effect)
            if cardResponded then
                if use_event then
                    local use = use_event.data[1]
                    use.extra_data = use.extra_data or {}
                    use.extra_data.ysch2_ronghun = use.extra_data.ysch2_ronghun or {}
                    table.insertIfNeed(use.extra_data.ysch2_ronghun, {currentResponser.id, cardResponded})
                end
                room:responseCard({
                    from = currentResponser.id,
                    card = cardResponded,
                    responseToEvent = effect,
                })
            else
            break
            end
        end

        if not cardResponded then
            break
        end

        currentTurn = currentTurn % 2 + 1
        currentResponser = responsers[currentTurn]
        end

        if currentResponser:isAlive() then
        room:damage({
            from = responsers[currentTurn % 2 + 1],
            to = currentResponser,
            card = effect.card,
            damage = 1,
            damageType = fk.NormalDamage,
            skillName = self.name,
        })
        end
    end
}
local ronghun_trigger = fk.CreateTriggerSkill{
    name = "#ysch2_ronghun_trigger",
    mute = true,
    refresh_events = {fk.PreCardEffect},
    can_refresh = function(self, event, target, player, data)
        return data.from == player.id and table.contains(data.card.skillNames, "ysch2_ronghun")
    end,
    on_refresh = function(self, event, target, player, data)
        local card = data.card:clone()
        local c = table.simpleClone(data.card)
        for k, v in pairs(c) do
            card[k] = v
        end
        if data.card.trueName == "fire_attack" then
            card.skill = ronghun_fireAttackSkill
        else
            card.skill = ronghun_duelSkill
        end
        data.card = card
    end,
}
Fk:addSkill(ronghun_fireAttackSkill)
Fk:addSkill(ronghun_duelSkill)
ronghun:addRelatedSkill(ronghun_trigger)
Surtr:addSkill(ronghun)
local yujin = fk.CreateTriggerSkill{
    name = "ysch2_yujin",
    mute = true,
    frequency = Skill.Compulsory,
    anim_type = "defensive",
    events = {fk.BeforeHpChanged, fk.TurnEnd},
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(self) and target == player then
            if event == fk.BeforeHpChanged then
                return data.num < 0 and player.hp + data.num < 1
                and player:getMark("ysch2_yujin_dying") == 0
            else
                return player:getMark("@@ysch2_yujin") == 1
            end
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        if event == fk.BeforeHpChanged then
            room:notifySkillInvoked(player,self.name,"defensive")
            player:broadcastSkillInvoke(self.name,math.random(1,2))
            data.preventDying = true
            room:setPlayerMark(player, "@@ysch2_yujin", 1)
        else
            room:notifySkillInvoked(player,self.name,"negative")
            player:broadcastSkillInvoke(self.name,3)
            room:setPlayerMark(player, "@@ysch2_yujin", 0)
            room:setPlayerMark(player, "ysch2_yujin_dying", 1)
            room:enterDying({who = player.id})
        end
    end,
}
Surtr:addSkill(yujin)
Fk:loadTranslationTable{
    ["ysch2_ronghun"] = "熔魂",
    [":ysch2_ronghun"] = "出牌阶段限一次，你可以视为使用【火攻】与之展示牌；或【决斗】与之打出牌。",
    ["#ysch2_ronghun-use"] = "熔魂：你可以视为使用这些牌",
    ["ysch2_yujin"] = "余烬",
    ["@@ysch2_yujin"] = "<font color='#a93135'>余烬</font>",
    [":ysch2_yujin"] = "锁定技，你的首个濒死结算延迟至你回合结束。",

    ["$ysch2_ronghun1"] = "一个也别想逃走。",
    ["$ysch2_ronghun2"] = "莱万汀！",
    ["$ysch2_yujin1"] = "没用的人都赶快撤退！这里我来。",
    ["$ysch2_yujin2"] = "我知道自己走。",
    ["$ysch2_yujin3"] = "（音效）",
}
local Fiddlesticks = General:new(extension, "ysch2__Fiddlesticks", "west", 3, 3, General.Male)--
Fiddlesticks.hidden = true
Fk:loadTranslationTable{
    ["ysch2__Fiddlesticks"] = "费德提克",
    ["#ysch2__Fiddlesticks"] = "远古恐惧",
    ["designer:ysch2__Fiddlesticks"] = "铝",
    ["cv:ysch2__Fiddlesticks"] = "未知",
    ["illustrator:ysch2__Fiddlesticks"] = "英雄联盟",
}
local wugufengdeng_amazing_graceSkill = fk.CreateActiveSkill{
    name = "ysch2_wugufengdeng_amazing_graceSkill",
    mute = true,
    prompt = "#amazing_grace_skill",
    can_use = Util.GlobalCanUse,
    on_use = Util.GlobalOnUse,
    mod_target_filter = Util.TrueFunc,
    on_action = function(self, room, use, finished)
        if not finished then
        local toDisplay = room:getNCards(#room.players)
        room:moveCards({
            ids = toDisplay,
            toArea = Card.Processing,
            moveReason = fk.ReasonPut,
            proposer = use.from,
        })

        table.forEach(room.players, function(p)
            room:fillAG(p, toDisplay)
        end)

        use.extra_data = use.extra_data or {}
        use.extra_data.AGFilled = toDisplay
        use.extra_data.AGResult = {}
        else
        if use.extra_data and use.extra_data.AGFilled then
            table.forEach(room.players, function(p)
            room:closeAG(p)
            end)

            local toDiscard = table.filter(use.extra_data.AGFilled, function(id)
            return room:getCardArea(id) == Card.Processing
            end)

            if #toDiscard > 0 then
            room:moveCards({
                ids = toDiscard,
                toArea = Card.DiscardPile,
                moveReason = fk.ReasonPutIntoDiscardPile,
            })
            end
        end

        use.extra_data.AGFilled = nil
        end
    end,
    on_effect = function(self, room, effect)
        local to = room:getPlayerById(effect.to)
        if not (effect.extra_data and effect.extra_data.AGFilled) then
        return
        end

        local chosen = room:askForAG(to, effect.extra_data.AGFilled, false, self.name)
        room:takeAG(to, chosen, room.players)
        table.insert(effect.extra_data.AGResult, {effect.to, chosen})
        room:moveCardTo(chosen, Card.PlayerHand, effect.to, fk.ReasonPrey, self.name, nil, true, effect.to)
        table.removeOne(effect.extra_data.AGFilled, chosen)
    end
}
Fk:addSkill(wugufengdeng_amazing_graceSkill)
local wugufengdeng = fk.CreateTriggerSkill{
    name = "ysch2_wugufengdeng",
    anim_type = "drawcard",
    events = {"fk.GeneralAppeared"},
    can_trigger = function (self, event, target, player, data)
        return target == player and player:hasShownSkill(self)
    end,
    on_cost = function(self, event, target, player, data)
        return player.room:askForSkillInvoke(player, self.name, nil, "#ysch2_wugufengdeng-invoke")
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        room:useVirtualCard("amazing_grace", nil, player, table.filter(room:getAlivePlayers(), function (p)
            return not player:isProhibited(p, Fk:cloneCard("amazing_grace")) end), self.name, false)
    end,

    refresh_events = {fk.BeforeCardUseEffect},
    can_refresh = function(self, event, target, player, data)
        return data.from == player.id and data.card.trueName == "amazing_grace" and data.card.skillName == self.name
    end,
    on_refresh = function (self, event, target, player, data)
        p(data.card.skillName)
        local card = data.card:clone()
        local c = table.simpleClone(data.card)
        for k, v in pairs(c) do
            card[k] = v
        end
        card.skill = wugufengdeng_amazing_graceSkill
        data.card = card
    end,
}
wugufengdeng.isHiddenSkill = true
Fiddlesticks:addSkill(wugufengdeng)
local wuhaicaoren = fk.CreateTriggerSkill{
    name = "ysch2_wuhaicaoren",
    events = {fk.TurnEnd},
    frequency = Skill.Compulsory,
    can_trigger = function (self, event, target, player, data)
        if player:hasSkill(self) then
            local room = player.room
            local logic = room.logic
            local current_event = logic:getCurrentEvent()
            local end_id = 0
            local turn_event = current_event:findParent(GameEvent.Turn, true)
            if turn_event == nil then return false end
            local events = room.logic:getEventsByRule(GameEvent.Turn, 3, function(e)
                end_id = e.id
                return true
            end, end_id)
            if end_id == 0 or #events < 3 then return end
            local last = logic:getEventsByRule(GameEvent.UseCard, 1, function (e)
                local d = e.data[1] ---@type CardUseStruct
                local pid = d.from
                local tos = d.tos
                return pid == player.id or (tos and table.contains(TargetGroup:getRealTargets(tos), player.id))
            end, end_id)
            if last[1] then return end
            return true
        end
    end,
    on_cost = Util.TrueFunc,
    --[[on_cost = function(self, event, target, player, data)
        return player.room:askForSkillInvoke(player, self.name, nil, "#ysch2_wuhaicaoren-invoke")
    end,]]--
    on_use = function (self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(player,"ysch2_qunyafengbao-round",0)
        if not player.dead then
            if player:getMark("__hidden_general") == 0 and player:getMark("__hidden_deputy") == 0 then
                DIYEnterHidden(player)
            end
        end
    end,
}
Fiddlesticks:addSkill(wuhaicaoren)
local qunyafengbao = fk.CreateTriggerSkill{
    name = "ysch2_qunyafengbao",
    anim_type = "offensive",
    events = {fk.AfterCardsMove},
    can_trigger = function (self, event, target, player, data)
        local mark = type(player:getMark("ysch2_qunyafengbao-round")) == "table" and player:getMark("ysch2_qunyafengbao-round") or {}
        return
            player:hasSkill(self) and
            table.find(
            data,
            function(info)
                return
                (info.moveReason ~= fk.ReasonUse or not player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)) and
                info.toArea == Card.DiscardPile and
                table.find(info.moveInfo, function(moveInfo) return player.room:getCardArea(moveInfo.cardId) == Card.DiscardPile end)
            end
            ) and #table.filter(table.map(player.room.alive_players, Util.IdMapper),function (id)
                return not table.contains(mark,id) and id ~= player.id
            end) > 0
    end,
    on_cost = function (self, event, target, player, data)
        local mark = type(player:getMark("ysch2_qunyafengbao-round")) == "table" and player:getMark("ysch2_qunyafengbao-round") or {}
        local tos = player.room:askForChoosePlayers(player, table.filter(table.map(player.room.alive_players, Util.IdMapper),function (id)
            return not table.contains(mark,id) and id ~= player.id
        end), 1, 1, "#ysch2_qunyafengbao-choose", self.name, true)
        if #tos > 0 then
            self.cost_data = {tos = tos}
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local to = room:getPlayerById(self.cost_data.tos[1])
        local mark = type(player:getMark("ysch2_qunyafengbao-round")) == "table" and player:getMark("ysch2_qunyafengbao-round") or {}
        table.insert(mark,to.id)
        room:setPlayerMark(player,"ysch2_qunyafengbao-round",mark)
        local cards = {}
        local suits = {}
        for _, info in ipairs(data) do
            if
            (info.moveReason ~= fk.ReasonUse or not room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)) and
            info.toArea == Card.DiscardPile
            then
                local cardsInDiscardPile = table.filter(
                    info.moveInfo,
                    function(moveInfo) return room:getCardArea(moveInfo.cardId) == Card.DiscardPile end
                )

                if #cardsInDiscardPile > 0 then
                    table.insertTable(
                    cards,
                    table.map(
                        cardsInDiscardPile,
                        function(moveInfo) return moveInfo.cardId end
                    )
                    )
                end
            end
        end
        for _, id in ipairs(cards) do
            local suit = Fk:getCardById(id):getSuitString()
            table.insertIfNeed(suits,suit)
        end
        local cards = room:askForDiscard(to, 1, 1, true, self.name, true,  ".|.|" .. table.concat(suits, ",") .."|hand" , "#ysch2_qunyafengbao-throw::"..player.id)
        if not cards or #cards == 0 then
            room:damage({
                from = player,
                to = to,
                damage = 1,
                skillName = self.name
            })
        end
    end,
}
Fiddlesticks:addSkill(qunyafengbao)
Fk:loadTranslationTable{
    ["ysch2_wugufengdeng_amazing_graceSkill"] = "五骨丰登",
    ["ysch2_wugufengdeng"] = "五骨丰登",
    [":ysch2_wugufengdeng"] = "隐匿。你登场后，可视为使用一张亮出游戏人数张牌的【五谷丰登】。",
    ["#ysch2_wugufengdeng-invoke"] = "是否发动 五骨丰登，视为使用一张【五谷丰登】",
    ["ysch2_wuhaicaoren"] = "巫骇",
    [":ysch2_wuhaicaoren"] = "锁定技，你连续三回合未使用或被使用牌时，重置“群鸦风暴”然后隐匿。",
    --["#ysch2_wuhaicaoren-invoke"] = "是否发动 巫骇，重置“群鸦风暴”然后隐匿",
    ["ysch2_qunyafengbao"] = "群鸦风暴",
    [":ysch2_qunyafengbao"] = "每轮每名角色限一次，有牌不因使用进入弃牌堆后，你可以令一名其他角色弃置与其中一张同颜色的一张手牌，否则你对其造成1点伤害。",
    ["#ysch2_qunyafengbao-choose"] = "是否发动 群鸦风暴，令一名其他角色弃置一张同色牌，否则你对其造成1点伤害",
    ["#ysch2_qunyafengbao-throw"] = "群鸦风暴：弃置一张同色牌，否则受到%dest造成的1点伤害",

    ["$ysch2_wugufengdeng1"] = "恐惧！",
    ["$ysch2_wugufengdeng2"] = "根本……没什么好怕的！",
    ["$ysch2_wugufengdeng3"] = "一分耕耘……一份收货",
    ["$ysch2_wugufengdeng4"] = "我会帮你……只要跟着我的声音",
    ["$ysch2_wuhaicaoren1"] = "它不会死的！",
    ["$ysch2_wuhaicaoren2"] = "有人在吗？",
    ["$ysch2_wuhaicaoren3"] = "不要害怕……它不会害你的",
    ["$ysch2_wuhaicaoren4"] = "天黑了……我找不到路了",
    ["$ysch2_qunyafengbao1"] = "（乌鸦叫）",
    ["$ysch2_qunyafengbao2"] = "别扔下我！",
    ["$ysch2_qunyafengbao3"] = "让我进去！",
    ["$ysch2_qunyafengbao4"] = "故事是真的！",
    ["$ysch2_qunyafengbao5"] = "你怕了吗？",
    ["$ysch2_qunyafengbao6"] = "是稻草人！",
    ["$ysch2_qunyafengbao7"] = "它是活的！",
    ["$ysch2_qunyafengbao8"] = "我听见了鸦群",

    ["~ysch2__Fiddlesticks"] = "费德提克……费德提克！",
}
local Shinano = General:new(extension, "ysch2__Shinano", "wei", 3, 3, General.Female)--
Shinano.shield = 1
Fk:loadTranslationTable{
    ["ysch2__Shinano"] = "信浓",
    ["#ysch2__Shinano"] = "大梦与初",
    ["designer:ysch2__Shinano"] = "铝",
    ["cv:ysch2__Shinano"] = "未知",
    ["illustrator:ysch2__Shinano"] = "碧蓝航线",
}
local distributionSelectSkill = fk.CreateActiveSkill{
    name = "ysch_Al_distribution_select_skill",
    mute = true,
    min_card_num = 1,
    expand_pile = function (self)
        local choices = {}
        for _, id in ipairs(Self:getCardIds("j")) do
            if table.contains(self.cards, id) then
                table.insert(choices,id)
            end
        end
        return choices
    end,
    card_filter = function(self, to_select, selected)
        local maxNum = 0
        for _, v in pairs(self.residued_list) do
            maxNum = math.max(maxNum, v)
        end
        return #selected < self.max_num and #selected < maxNum and table.contains(self.cards, to_select)
    end,
    target_num = 1,
    target_filter = function(self, to_select, selected, selected_cards)
        return #selected == 0 and #selected_cards > 0 and table.contains(self.targets, to_select)
        and #selected_cards <= (self.residued_list[string.format("%d", to_select)] or 0)
    end,
}
Fk:addSkill(distributionSelectSkill)
--- 询问将卡牌分配给任意角色。
---@param self Room
---@param player ServerPlayer @ 要询问的玩家
---@param cards? integer[] @ 要分配的卡牌。默认拥有的所有牌
---@param targets? ServerPlayer[] @ 可以获得卡牌的角色。默认所有存活角色
---@param skillName? string @ 技能名，影响焦点信息。默认为“分配”
---@param minNum? integer @ 最少交出的卡牌数，默认0
---@param maxNum? integer @ 最多交出的卡牌数，默认所有牌
---@param prompt? string @ 询问提示信息
---@param expand_pile? string|integer[] @ 可选私人牌堆名称，如要分配你武将牌上的牌请填写
---@param skipMove? boolean @ 是否跳过移动。默认不跳过
---@param single_max? integer|table @ 限制每人能获得的最大牌数。输入整数或(以角色id为键以整数为值)的表
---@return table<integer, integer[]> @ 返回一个表，键为角色id，值为分配给其的牌id数组
local ysch_Al_yiji = function (self, player, cards, targets, skillName, minNum, maxNum, prompt, expand_pile, skipMove, single_max)
    targets = targets or self.alive_players
    cards = cards or player:getCardIds("he")
    local _cards = table.simpleClone(cards)
    targets = table.map(targets, Util.IdMapper)
    self:sortPlayersByAction(targets)
    skillName = skillName or "distribution_select_skill"
    minNum = minNum or 0
    maxNum = maxNum or #cards
    local list = {}
    for _, pid in ipairs(targets) do
        list[pid] = {}
    end
    local toStr = function(int) return string.format("%d", int) end
    local residueMap = {}
    if type(single_max) == "table" then
        for pid, v in pairs(single_max) do
            residueMap[toStr(pid)] = v
        end
    end
    local residue_sum = 0
    local residue_num = type(single_max) == "number" and single_max or 9999
    for _, pid in ipairs(targets) do
        residueMap[toStr(pid)] = residueMap[toStr(pid)] or residue_num
        residue_sum = residue_sum + residueMap[toStr(pid)]
    end
    minNum = math.min(minNum, #_cards, residue_sum)
    local data = {
        cards = _cards,
        max_num = maxNum,
        targets = targets,
        residued_list = residueMap,
        expand_pile = expand_pile
    }
  
    while maxNum > 0 and #_cards > 0 do
        data.max_num = maxNum
        prompt = prompt or ("#AskForDistribution:::"..minNum..":"..maxNum)
        local success, dat = self:askForUseActiveSkill(player, "ysch_Al_distribution_select_skill", prompt, minNum == 0, data, true)
        if success and dat then
            local to = dat.targets[1]
            local give_cards = dat.cards
            for _, id in ipairs(give_cards) do
            table.insert(list[to], id)
            table.removeOne(_cards, id)
            local p = self:getPlayerById(to)
            self:setCardMark(Fk:getCardById(id), "@DistributionTo",
                Fk:translate(p.general == "anjiang" and "seat#" .. tostring(p.seat) or p.general))
            end
            minNum = math.max(0, minNum - #give_cards)
            maxNum = maxNum - #give_cards
            residueMap[toStr(to)] = residueMap[toStr(to)] - #give_cards
        else
            break
        end
    end
  
    for _, id in ipairs(cards) do
        self:setCardMark(Fk:getCardById(id), "@DistributionTo", 0)
    end
    for _, pid in ipairs(targets) do
        if minNum == 0 or #_cards == 0 then break end
        local num = math.min(residueMap[toStr(pid)] or 0, minNum, #_cards)
        if num > 0 then
            for i = num, 1, -1 do
                local c = table.remove(_cards, i)
                table.insert(list[pid], c)
                minNum = minNum - 1
            end
        end
    end
    if not skipMove then
        self:doYiji(list, player.id, skillName)
    end
  
    return list
end

local xingyue = fk.CreateTriggerSkill{
    name = "ysch2_xingyue",
    frequency = Skill.Compulsory,
    mute = true,
    events = {fk.GameStart,fk.EventPhaseChanging},
    can_trigger = function (self, event, target, player, data)
        if event == fk.GameStart then
            return player:hasSkill(self.name)
        else
            return data.to == Player.Judge and player:hasSkill(self.name) and target == player
        end
    end,
    on_cost = function (self, event, target, player, data)
        if event ~= fk.GameStart then
            local room = player.room
            local choices = {}
            if not player:isKongcheng() and not player.dead and not table.contains(player.sealedSlots, Player.JudgeSlot) then
                table.insert(choices,"#ysch2_xingyue-choices1")
            end
            table.insert(choices,"#ysch2_xingyue-choices2")
            if #player:getCardIds("hej") > 0 then
                table.insert(choices,"#ysch2_xingyue-choices3") 
            end
            local choice = room:askForChoice(player, choices, self.name, "#ysch2_xingyue", false)
            self.cost_data = choice
        end
        return true
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        if event == fk.GameStart then
            room:notifySkillInvoked(player, self.name, "drawcard")
            local cards = room:getCardsFromPileByRule("peach", 2)
            if #cards > 0 then
                room:moveCards({
                    ids = cards,
                    to = player.id,
                    toArea = Card.PlayerHand,
                    moveReason = fk.ReasonJustMove,
                    proposer = player.id,
                    skillName = self.name,
                })
            end
            local numCard = 0
            while numCard < 3 and not player:isKongcheng() and not player.dead and not table.contains(player.sealedSlots, Player.JudgeSlot) do
                numCard = numCard + 1
                local puts = player.room:askForCard(player, 1, 1, false, self.name, false, "", "#ysch2_xingyue-put")
                if #puts > 0 then
                    premeditate(player, puts[1], self.name, player.id)
                end
            end
        else
            if self.cost_data == "#ysch2_xingyue-choices1" then
                room:notifySkillInvoked(player, self.name, "offensive")
                local puts = player.room:askForCard(player, 1, 1, false, self.name, false, "", "#ysch2_xingyue-put")
                if #puts > 0 then
                    premeditate(player, puts[1], self.name, player.id)
                end
            elseif self.cost_data == "#ysch2_xingyue-choices2" then
                room:notifySkillInvoked(player, self.name, "special")
                room:askForGuanxing(player, room:getNCards(2), nil, nil, self.name)
            else
                room:notifySkillInvoked(player, self.name, "support")
                local cards = table.simpleClone(player:getCardIds("hej"))
                local targets = room.alive_players
                targets = table.map(targets, Util.IdMapper)
                room:sortPlayersByAction(targets)

                ysch_Al_yiji(room, player, player:getCardIds("hej"), room:getOtherPlayers(player), self.name, 3, 3)
            end
            return true
        end
    end,
}
Shinano:addSkill(xingyue)

local youdie = fk.CreateViewAsSkill{
    name = "ysch2_youdie",
    pattern = ".",
    expand_pile = function (self)
        local choices = {}
        for _, id in ipairs(Self:getTableMark("ysch2_youdie")) do
            local card = Fk:getCardById(id)
            local flag = card.name[#card.name]
            if #Self:getCardIds(flag) > 0 then
                table.insert(choices,id)
            end
        end
        return choices
    end,
    interaction = function()
        local names = {}
        local mark = type(Self:getMark("ysch2_youdie_name")) == "table" and Self:getMark("ysch2_youdie_name") or {}
        table.insertIfNeed(mark, "jink")
        table.insertIfNeed(mark, "nullification")
        for _, na in ipairs(mark) do
            if Fk.currentResponsePattern == nil then
                local card = Fk:cloneCard(na)
                if not table.contains({"jink","nullification"},na) and Self:canUse(card) and not Self:prohibitUse(card) then
                    table.insertIfNeed(names, na)
                end
            elseif Fk.currentResponsePattern then
                local card = Fk:cloneCard(na)
                if Exppattern:Parse(Fk.currentResponsePattern):match(card) then
                    table.insertIfNeed(names, na)
                end
            end
        end
        if #names == 0 then return false end
        return U.CardNameBox{choices = names}
    end,
    card_filter = function(self, to_select, selected)
        if #selected == 0 then
            local card = Fk:getCardById(to_select)
            return table.contains({"ysch_Al_h","ysch_Al_e","ysch_Al_j"},card.name)
        end
    end,
    view_as = function (self, cards, player)
        if not self.interaction.data  or #cards ~= 1 then return end
        local card = Fk:cloneCard(self.interaction.data)
        local select = Fk:getCardById(cards[1])
        local flag = select.name[#select.name]
        card:addSubcards(player:getCardIds(flag))
        return card
    end,
    before_use = function (self, player, use)
        local mark = type(Self:getMark("ysch2_youdie_name")) == "table" and Self:getMark("ysch2_youdie_name") or {}
        if table.contains(mark,use.card.name) then
            table.removeOne(mark,use.card.name)
        end
        if #mark > 0 then
            player.room:setPlayerMark(player,"@ysch2_youdie",table.concat(table.map(mark, Util.TranslateMapper)," "))
        else
            player.room:setPlayerMark(player,"@ysch2_youdie",0)
        end
        player.room:setPlayerMark(player,"ysch2_youdie_name",mark)
    end,
    after_use = function (self, player, use)
        if table.find(use.card.subcards, function (id)
            return Fk:getCardById(id).type == Card.TypeTrick
        end) then
            player:drawCards(1, self.name)
        end
        if table.find(use.card.subcards, function (id)
            return Fk:getCardById(id).type == Card.TypeEquip
        end) then
            local names = getAllCardNames("bt")
            for _, v in ipairs({"jink","nullification",use.card.name}) do
                if table.contains(names,v) then
                    table.removeOne(names,v)
                end
            end
            local choice = player.room:askForChoice(player, names, self.name, "#ysch2_youdie")
            local mark = type(player:getMark("ysch2_youdie_name")) == "table" and player:getMark("ysch2_youdie_name") or {}
            table.insert(mark,choice)
            player.room:setPlayerMark(player,"@ysch2_youdie",table.concat(table.map(mark, Util.TranslateMapper)," "))
            player.room:setPlayerMark(player,"ysch2_youdie_name",mark)
        end
    end,
}
local youdie_trigger = fk.CreateTriggerSkill{
    name = "#ysch2_youdie_trigger",
    refresh_events = {fk.GameStart},
    can_refresh = function (self, event, target, player, data)
        return player:hasSkill(youdie.name)
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        local mark = {}
        for _, flag in ipairs({"h", "e", "j"}) do
            local str = "ysch_Al_"..flag
            local card = room:printCard(str)
            table.insert(mark,card.id)
        end
        room:setPlayerMark(player,"ysch2_youdie",mark)
    end,
}
youdie:addRelatedSkill(youdie_trigger)
Shinano:addSkill(youdie)
Fk:loadTranslationTable{
    ["ysch2_xingyue"] = "星月",
    [":ysch2_xingyue"] = "锁定技，游戏开始时，你获得两张【桃】并<a href='ysch_xumou'>蓄谋</a>3。你的判定阶段改为选择一项：1.<a href='ysch_xumou'>蓄谋</a>1；2.卜算2；3.分配你区域内三张牌。",
    ["ysch_xumou"] = "<b>蓄谋</b>：将一张手牌扣置于判定区，判定阶段开始时，按置入顺序（后置入的先处理）依次处理“蓄谋”牌：1.使用此牌，"..
    "然后此阶段不能再使用此牌名的牌；2.将所有“蓄谋”牌置入弃牌堆。",
    ["#ysch2_xingyue-put"] = "星月：将一张手牌作为“蓄谋”牌扣置于判定区",
    ["#ysch2_xingyue"] = "星月：请选择一项",
    ["#ysch2_xingyue-choices1"] = "蓄谋1",
    ["#ysch2_xingyue-choices2"] = "卜算2",
    ["#ysch2_xingyue-choices3"] = "分配区域内三张牌",
    ["ysch2_youdie"] = "幽蝶",
    [":ysch2_youdie"] = "你可以将一个区域内所有牌当【闪】/【无懈可击】使用。结算后，若包含：锦囊牌，你摸一张牌；装备牌，你声明一种即时牌名加入此技能并于发动时清除。",
    ["#ysch2_youdie"] = "幽蝶：声明一种牌名，令此技能可印该牌",
    ["@ysch2_youdie"] = "幽蝶",
}
local SuperFly = General:new(extension, "ysch2__SuperFly", "qun", 4, 4, General.Male)--
Fk:loadTranslationTable{
    ["ysch2__SuperFly"] = "钢田一丰大",
    ["#ysch2__SuperFly"] = "超级飞人",
    ["designer:ysch2__SuperFly"] = "铝&wm233",
    ["cv:ysch2__SuperFly"] = "远近孝一",
    ["illustrator:ysch2__SuperFly"] = "荒木飞吕彦",
}
local tietajingu = fk.CreateTriggerSkill{
    name = "ysch2_tietajingu",
    mute = true,
    frequency = Skill.Compulsory,
    events = {fk.GameStart,fk.BeforeTurnOver,fk.RoundEnd},
    can_trigger = function (self, event, target, player, data)
        if player:hasSkill(self.name) then
            if event == fk.GameStart then
                return true
            elseif event == fk.BeforeTurnOver then
                return not target.faceup and #table.filter(player.room.alive_players,function (cp)
                    return cp.id ~= target.id and not cp.faceup
                end) == 0
            else
                return #table.filter(player.room.alive_players,function (cp)
                    return not cp.faceup
                end) > 0
            end
        end
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        if event == fk.GameStart then
            room:notifySkillInvoked(player,self.name,"offensive")
            if not player.dead then
                player:turnOver()
            end
        elseif event == fk.BeforeTurnOver then
            room:notifySkillInvoked(player,self.name,"drawcard")
            target:drawCards(1,self.name)
            return true
        else
            room:notifySkillInvoked(player,self.name,"special")
            for _, cp in ipairs(room.alive_players) do
                if not cp.faceup then
                    room:setPlayerMark(cp, "@@ysch2_tietajingu-phase", 1)
                    cp:gainAnExtraPhase(Player.Play)
                end
            end
        end
    end,
}
local tietajingu_prohibit = fk.CreateProhibitSkill{
    name = "#tietajingu_prohibit",
    is_prohibited = function(self, from, to, card)
        return from:getMark("@@ysch2_tietajingu-phase") > 0 and to.faceup and from.phase == Player.Play
    end,
}
tietajingu:addRelatedSkill(tietajingu_prohibit)
SuperFly:addSkill(tietajingu)
local ganggufanshi = fk.CreateTriggerSkill{
    name = "ysch2_ganggufanshi",
    events = {fk.TargetSpecified},
    can_trigger = function (self, event, target, player, data)
        if player:hasSkill(self.name) and target ~= player and data.from ~= data.to and AimGroup:isOnlyTarget(player.room:getPlayerById(data.to), data) and #table.filter(player.room.alive_players,function (cp)
            return not cp.faceup
        end) == 1 then
            if data.extra_data and data.extra_data.ysch2_ganggufanshi then return false end
            local room = player.room
            local turnCp = table.filter(player.room.alive_players,function (cp)
                return not cp.faceup
            end)[1]
            local ret, left, right = {}, {}, {}
            local from, to = room:getPlayerById(data.from), room:getPlayerById(data.to)
            table.insert(ret,to.id)
            local temp = from.next
            while temp ~= to do
            if temp:isAlive() then
                table.insert(right, temp.id)
            end
            temp = temp.next
            end
            temp = to.next
            while temp ~= from do
            if temp:isAlive() then
                table.insert(left, temp.id)
            end
            temp = temp.next
            end
            local min_dist = math.min(#left, #right)
            if #left == min_dist then
                table.insertTable(ret, left)
            end
            if #right == min_dist then
                table.insertTable(ret, right)
            end
            return table.find(ret,function (id)
                return id == turnCp.id
            end)
        end
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local turnCp = table.filter(player.room.alive_players,function (cp)
            return not cp.faceup
        end)[1]
        if room:askForSkillInvoke(turnCp,self.name,nil,"#ysch2_ganggufanshi-choose::"..data.from) then
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local turnCp = table.filter(player.room.alive_players,function (cp)
            return not cp.faceup
        end)[1]
        local choices = {}
        local from, to = room:getPlayerById(data.from), room:getPlayerById(data.to)
        table.insert(choices,"#ysch2_ganggufanshi-choice1")
        if to.id ~= turnCp.id then
            table.insert(choices,"#ysch2_ganggufanshi-choice2::"..turnCp.id)
        end
        local result = room:askForChoice(from,choices,self.name,"#ysch2_ganggufanshi-choice")
        if result == "#ysch2_ganggufanshi-choice1" then
            from:turnOver()
        else
            data.extra_data = data.extra_data or {}
            data.extra_data.ysch2_ganggufanshi = true
            room:sendLog{ type = "#ysch2_ganggufanshi-Changetargets", from = from.id, to = {turnCp.id}, arg = self.name, arg2 = data.card:toLogString()}
            AimGroup:cancelTarget(data, data.to)
            AimGroup:addTargets(room, data, turnCp.id)
        end
    end,
}
SuperFly:addSkill(ganggufanshi)
local juejingjiaodou = fk.CreateTriggerSkill{
    name = "ysch2_juejingjiaodou",
    frequency = Skill.Limited,
    events = {fk.EnterDying},
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0 then
            return #table.filter(player.room.alive_players,function (cp)
                return not cp.faceup
            end) == 1
        end
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local turnCp = table.filter(player.room.alive_players,function (cp)
            return not cp.faceup
        end)[1]
        local tos = room:askForChoosePlayers(turnCp, table.map(room:getOtherPlayers(turnCp), Util.IdMapper), 1, 1, "#ysch2_juejingjiaodou-invoke::"..target.id, self.name, true)
        if #tos > 0 then
            self.cost_data = tos[1]
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local turnCp = table.filter(player.room.alive_players,function (cp)
            return not cp.faceup
        end)[1]
        local tp = room:getPlayerById(self.cost_data)
        room:recover({
            who = target,
            num = 1 - target.hp,
            recoverBy = player,
            skillName = self.name,
        })
        tp:turnOver()
        turnCp:turnOver()
    end,
}
SuperFly:addSkill(juejingjiaodou)
Fk:loadTranslationTable{
    ["@@ysch2_tietajingu-phase"] = "铁塔禁锢",
    ["ysch2_tietajingu"] = "铁塔禁锢",
    [":ysch2_tietajingu"] = "锁定技，游戏开始时，你翻面。场上唯一背面朝上的角色翻面时，摸一张牌取消之。轮次结束时，背面朝上的角色依次执行一个仅能对彼此使用牌的出牌阶段。",
    ["ysch2_ganggufanshi"] = "钢骨反噬",
    [":ysch2_ganggufanshi"] = "其他角色使用目标唯一牌的最短路径经过场上唯一背面朝上的另一名角色时，后者可以令前者选择翻面或将此牌目标改为其。",
    ["#ysch2_ganggufanshi-choose"] = "钢骨反噬：是否令%dest选择翻面或将此牌目标改为你",
    ["#ysch2_ganggufanshi-choice"] = "钢骨反噬：选择一项",
    ["#ysch2_ganggufanshi-choice1"] = "翻面",
    ["#ysch2_ganggufanshi-choice2"] = "将目标改为%dest",
    ["#ysch2_ganggufanshi-Changetargets"] = "由于 %arg 的效果，%from 使用的 %arg2 目标改为 %to",
    ["ysch2_juejingjiaodou"] = "绝境角斗",
    [":ysch2_juejingjiaodou"] = "限定技，有角色进入濒死时，场上唯一背面朝上的角色可以令其回复至1点体力，并翻面另一名角色和自己。",
    ["#ysch2_juejingjiaodou-invoke"] = "绝境角斗：你可以令%dest回复至1点体力，并翻面另一名角色和自己",
}
local RAMATTRA = General:new(extension, "ysch2__RAMATTRA", "west", 3, 4, General.Male)--
Fk:loadTranslationTable{
    ["ysch2__RAMATTRA"] = "拉玛刹",
    ["#ysch2__RAMATTRA"] = "ラマットラ",
    ["designer:ysch2__RAMATTRA"] = "铝",
    ["cv:ysch2__RAMATTRA"] = "未知",
    ["illustrator:ysch2__RAMATTRA"] = "守望先锋",
}
local zhang = fk.CreateViewAsSkill{
    name = "ysch2_zhang",
    pattern = "peach",
    view_as = function(self, cards)
        if #cards ~= 1 then return nil end
        local c = Fk:cloneCard("peach")
        c.skillName = self.name
        c:setMark(self.name, cards[1])
        return c
    end,
    card_filter = function(self, to_select, selected)
        local card = Fk:getCardById(to_select)
        return #selected == 0 and card.color == Card.Black
    end,
    before_use = function (self, player, use)
        local room = player.room
        player:broadcastSkillInvoke("ysch2_zhang")
        local put = use.card:getMark(self.name)
        if put ~= 0 and table.contains(player:getCardIds("he"), put) then
            room:throwCard(put, self.name, player, player)
        end
        local targets = {}
        for _, p in ipairs(room.alive_players) do
            if not table.contains(p.sealedSlots, Player.ArmorSlot) then
              table.insert(targets, p.id)
            end
        end
        if #targets == 0 then return "" end
        local tos = room:askForChoosePlayers(player, targets, 1, 1, "#ysch2_zhang-choose", self.name, false)
        if #tos > 0 then
            local orig_card = Fk.all_card_types["ysch_Al__breastplate"]
            if not orig_card then return "" end
            local card = room:printCard("ysch_Al__breastplate", orig_card.suit, orig_card.number)
            room:setCardMark(card, MarkEnum.DestructIntoDiscard, 1)
            room:useCard{from = player.id, tos = {{tos[1]}}, card = card}
        end
        room:setPlayerMark(player, "ysch2_zhang-failed-phase", 1)
        return ""
    end,
    enabled_at_play = function (self, player)
        return #table.filter(player:getCardIds("he"), function (id)
            return Fk:getCardById(id).color == Card.Black
        end) > 0 and player:getMark("ysch2_zhang-failed-phase") == 0
    end,
    enabled_at_response = function (self, player, response)
        return not response and #table.filter(player:getCardIds("he"), function (id)
            return Fk:getCardById(id).color == Card.Black
        end) > 0 and player:getMark("ysch2_zhang-failed-phase") == 0
    end,
}
local zhang_trigger = fk.CreateTriggerSkill{
    name = "#ysch2_zhang_trigger",
    anim_type = "drawcard",
    main_skill = zhang,
    refresh_events = {fk.AskForCardUse, fk.AskForCardResponse, fk.AfterAskForCardUse, fk.AfterAskForCardResponse, fk.PreCardUse, fk.CardUseFinished, fk.SkillEffect, fk.AfterSkillEffect},
    can_refresh = function (self, event, target, player, data)
        return player:getMark("ysch2_zhang-failed-phase") ~= 0
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(player, "ysch2_zhang-failed-phase", 0)
    end,
}
zhang:addRelatedSkill(zhang_trigger)
RAMATTRA:addSkill(zhang)
local zhu = fk.CreateActiveSkill{
    name = "ysch2_zhu",
    card_num = 0,
    target_num = 0,
    card_filter = Util.FalseFunc,
    target_filter = Util.FalseFunc,
    can_use = function(self, player)
        return player:getMark("@@rfenghou_readying:::"..self.name) == 0
    end,
    on_use = function (self, room, effect)
        local player = room:getPlayerById(effect.from)
        local cards = player.room:getCardsFromPileByRule("slash", 1, "discardPile")
        if #cards > 0 then
            player.room:obtainCard(player, cards[1], true, fk.ReasonJustMove)
        end
        local skills = {}
        for _, skill in ipairs(player.player_skills) do
            if skill:isPlayerSkill(player) then
                table.insert(skills, skill.name)
            end
        end
        room:setPlayerMark(player,"ysch2_zhu",skills)
        room:handleAddLoseSkills(player,"-"..table.concat(skills,"|-").."|ysch2_tian|ysch2_fa",nil,true)
    end,
}
zhu.RfenghouReadySkill = true
RAMATTRA:addSkill(zhu)
local tian = fk.CreateTriggerSkill{
    name = "ysch2_tian",
    events = {fk.CardUseFinished, fk.AfterCardsMove},
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(self) then
            local room = player.room
            local choices = table.map(player:getTableMark("@ysch2_tian"), function (choice)
                return "#"..string.sub(choice, 2)
            end)
            if #choices == 4 then
                table.removeOne(choices,"#ysch2_tian4")
            end
            local targets = table.filter(room.alive_players, function (p)
                return #p:getCardIds("ej") > 0
            end)
            if #targets == 0 then table.removeOne(choices,"#ysch2_tian3") end
            if event == fk.CardUseFinished then
                table.removeOne(choices,"#ysch2_tian1")
                return target == player and data.card.trueName == "slash" and not(data.extra_data and data.extra_data.ysch2_tian) and #choices > 0
            elseif event == fk.AfterCardsMove then
                for _, move in ipairs(data) do
                    if move.moveReason == fk.ReasonDraw then
                        if move.to == player.id and move.skillName ~= self.name and #move.moveInfo == 1 then
                            table.removeOne(choices,"#ysch2_tian2")
                            if #choices > 0 then return true end
                        end
                    elseif move.moveReason == fk.ReasonDiscard then
                        if #move.moveInfo > 0 and move.skillName ~= self.name and ((move.proposer and  move.proposer == player.id) or (move.from and move.from == player.id)) then
                            for _, info in ipairs(move.moveInfo) do
                                if table.contains({Card.PlayerEquip,Card.PlayerJudge},info.fromArea) then
                                    if table.contains(choices,"#ysch2_tian3") then table.removeOne(choices,"#ysch2_tian3") end
                                    if #choices > 0 then return true end
                                end
                            end
                        end
                    end
                end
            end
        end
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local choices, all_choices = table.map(player:getTableMark("@ysch2_tian"), function (choice)
            return "#"..string.sub(choice, 2)
        end), table.map(player:getTableMark("@ysch2_tian"), function (choice)
            return "#"..string.sub(choice, 2)
        end)
        if #choices == 4 then
            table.removeOne(choices,"#ysch2_tian4")
        end
        if event == fk.CardUseFinished then
            table.removeOne(choices,"#ysch2_tian1")
        else
            for _, move in ipairs(data) do
                if move.moveReason == fk.ReasonDraw then
                    table.removeOne(choices,"#ysch2_tian2")
                    break
                elseif move.moveReason == fk.ReasonDiscard then
                    table.removeOne(choices,"#ysch2_tian3")
                    break
                end
            end
        end
        if table.contains(choices,"#ysch2_tian3") then
            local targets = table.filter(room.alive_players, function (p)
                return #p:getCardIds("ej") > 0
            end)
            if #targets == 0 then table.removeOne(choices,"#ysch2_tian3") end
        end
        if #choices > 0 then
            table.insert(choices,"Cancel")
            table.insert(all_choices,"Cancel")
            local result = room:askForChoice(player,choices,self.name,"#ysch2_tian-prompt",false,all_choices)
            if result ~= "Cancel" then
                self.cost_data = result
                return true
            end
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        player:broadcastSkillInvoke("ysch2_fa")
        local marks = player:getTableMark("@ysch2_tian")
        table.removeOne(marks,"@"..string.sub(self.cost_data, 2))
        room:setPlayerMark(player, "@ysch2_tian",marks)
        if self.cost_data == "#ysch2_tian1" then
            local use = room:askForUseCard(player, "slash", "slash", "#ysch2_tian-slash", true)
            if use then
                use.extraUse = true
                use.extra_data = use.extra_data or {}
                use.extra_data.ysch2_tian = true
                room:useCard(use)
            end
        elseif self.cost_data == "#ysch2_tian2" then
            player:drawCards(1, self.name)
        elseif self.cost_data == "#ysch2_tian3" then
            local targets = table.filter(room.alive_players, function (p)
                return #p:getCardIds("ej") > 0
            end)
            if #targets > 0 then
                local to = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#ysch2_tian-discard", self.name, false)
                to = room:getPlayerById(to[1])
                local card = #to:getCardIds("ej") == 1 and to:getCardIds("ej") or room:askForCardChosen(player, to, "ej", self.name, "#ysch2_tian-discard")
                room:throwCard(card, self.name, to, player)
            end
        else
            room:setPlayerMark(player, "@ysch2_tian", {"@ysch2_tian1", "@ysch2_tian2", "@ysch2_tian3", "@ysch2_tian4"})
        end
    end,
    on_acquire = function (self, player, is_start)
        player.room:setPlayerMark(player, "@ysch2_tian", {"@ysch2_tian1", "@ysch2_tian2", "@ysch2_tian3", "@ysch2_tian4"})
    end,
    on_lose = function (self, player, is_death)
        player.room:setPlayerMark(player, "@ysch2_tian", 0)
    end,

    refresh_events = {fk.RoundEnd},
    can_refresh = function (self, event, target, player, data)
        return player:getMark("ysch2_zhu") ~= 0
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        local skills = player:getMark("ysch2_zhu")
        room:setPlayerMark(player,"ysch2_zhu",0)
        room:handleAddLoseSkills(player,table.concat(skills,"|").."|-ysch2_tian|-ysch2_fa",nil,true)
    end,
}
local tian_targetmod = fk.CreateTargetModSkill{
    name = "#ysch2_tian_targetmod",
    main_skill = tian,
    residue_func = function(self, player, skill, scope)
        if player:hasSkill(tian) and skill.trueName == "slash_skill" and scope == Player.HistoryPhase then
            return 1
        end
    end,
}
tian:addRelatedSkill(tian_targetmod)
Fk:addSkill(tian)
local fa = fk.CreateTriggerSkill{
    name = "ysch2_fa",
    events = {fk.CardUseFinished, fk.AfterCardsMove},
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(self) then
            local room = player.room
            local choices = table.map(player:getTableMark("@ysch2_fa"), function (choice)
                return "#"..string.sub(choice, 2)
            end)
            if #choices == 4 then
                table.removeOne(choices,"#ysch2_fa4")
            end
            local targets = table.filter(room.alive_players, function (p)
                return #p:getCardIds("ej") > 0
            end)
            if #targets == 0 then table.removeOne(choices,"#ysch2_fa3") end
            if event == fk.CardUseFinished then
                table.removeOne(choices,"#ysch2_fa1")
                return target == player and data.card.trueName == "slash" and not(data.extra_data and data.extra_data.ysch2_fa) and #choices > 0
            elseif event == fk.AfterCardsMove then
                for _, move in ipairs(data) do
                    if move.moveReason == fk.ReasonDraw then
                        if move.to == player.id and move.skillName ~= self.name and #move.moveInfo == 1 then
                            table.removeOne(choices,"#ysch2_fa2")
                            if #choices > 0 then return true end
                        end
                    elseif move.moveReason == fk.ReasonDiscard then
                        if #move.moveInfo > 0 and move.skillName ~= self.name and ((move.proposer and  move.proposer == player.id) or (move.from and move.from == player.id)) then
                            for _, info in ipairs(move.moveInfo) do
                                if table.contains({Card.PlayerEquip,Card.PlayerJudge},info.fromArea) then
                                    if table.contains(choices,"#ysch2_fa3") then table.removeOne(choices,"#ysch2_fa3") end
                                    if #choices > 0 then return true end
                                end
                            end
                        end
                    end
                end
            end
        end
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local choices, all_choices = table.map(player:getTableMark("@ysch2_fa"), function (choice)
            return "#"..string.sub(choice, 2)
        end),table.map(player:getTableMark("@ysch2_fa"), function (choice)
            return "#"..string.sub(choice, 2)
        end)
        if event == fk.CardUseFinished then
            table.removeOne(choices,"#ysch2_fa1")
        else
            for _, move in ipairs(data) do
                if move.moveReason == fk.ReasonDraw then
                    table.removeOne(choices,"#ysch2_fa2")
                    break
                elseif move.moveReason == fk.ReasonDiscard then
                    table.removeOne(choices,"#ysch2_fa3")
                    break
                end
            end
        end
        if table.contains(choices,"#ysch2_fa3") then
            local targets = table.filter(room.alive_players, function (p)
                return #p:getCardIds("ej") > 0
            end)
            if #targets == 0 then table.removeOne(choices,"#ysch2_fa3") end
        end
        if #choices > 0 then
            table.insert(choices,"Cancel")
            table.insert(all_choices,"Cancel")
            local result = room:askForChoice(player,choices,self.name,"#ysch2_tian-prompt",nil,all_choices)
            if result ~= "Cancel" then
                self.cost_data = result
                return true
            end
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local marks = player:getTableMark("@ysch2_fa")
        table.removeOne(marks,"@"..string.sub(self.cost_data, 2))
        room:setPlayerMark(player, "@ysch2_fa",marks)
        if self.cost_data == "#ysch2_fa1" then
            local use = room:askForUseCard(player, "slash", "slash", "#ysch2_tian-slash", true)
            if use then
                use.extraUse = true
                use.extra_data = use.extra_data or {}
                use.extra_data.ysch2_fa = true
                room:useCard(use)
            end
        elseif self.cost_data == "#ysch2_fa2" then
            player:drawCards(1, self.name)
        elseif self.cost_data == "#ysch2_fa3" then
            local targets = table.filter(room.alive_players, function (p)
                return #p:getCardIds("ej") > 0
            end)
            if #targets > 0 then
                local to = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#ysch2_tian-discard", self.name, false)
                to = room:getPlayerById(to[1])
                local card = #to:getCardIds("ej") == 1 and to:getCardIds("ej") or room:askForCardChosen(player, to, "ej", self.name, "#ysch2_tian-discard")
                room:throwCard(card, self.name, to, player)
            end
        else
            room:setPlayerMark(player, "@ysch2_fa", {"@ysch2_fa1", "@ysch2_fa2", "@ysch2_fa3", "@ysch2_fa4"})
        end
    end,
    on_acquire = function (self, player, is_start)
        player.room:setPlayerMark(player, "@ysch2_fa", {"@ysch2_fa1", "@ysch2_fa2", "@ysch2_fa3", "@ysch2_fa4"})
    end,
    on_lose = function (self, player, is_death)
        player.room:setPlayerMark(player, "@ysch2_fa", 0)
    end,

    refresh_events = {fk.AfterRoundEnd},
    can_refresh = function (self, event, target, player, data)
        return player:getMark("ysch2_zhu") ~= 0
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        local skills = player:getMark("ysch2_zhu")
        room:setPlayerMark(player,"ysch2_zhu",0)
        room:handleAddLoseSkills(player,table.concat(skills,"|").."|-ysch2_tian|-ysch2_fa",nil,true)
    end,
}
local fa_targetmod = fk.CreateTargetModSkill{
    name = "#ysch2_fa_targetmod",
    main_skill = tian,
    residue_func = function(self, player, skill, scope)
        if player:hasSkill(fa) and skill.trueName == "slash_skill" and scope == Player.HistoryPhase then
            return 1
        end
    end,
}
fa:addRelatedSkill(fa_targetmod)
RAMATTRA:addRelatedSkill(fa)
local RAMATTRA_win = fk.CreateActiveSkill{ name = "ysch2__RAMATTRA_win_audio" }
RAMATTRA_win.package = extension
Fk:addSkill(RAMATTRA_win)
Fk:loadTranslationTable{
    ["ysch2_zhang"] = "障",
    [":ysch2_zhang"] = "当你需要使用【桃】时，你可弃置一张黑色牌，令一名角色装备额外牌堆中的一张【护心镜】。",
    ["#ysch2_zhang_trigger"] = "障",
    ["#ysch2_zhang-choose"] = "障：令一名角色装备额外牌堆中的一张【护心镜】",
    ["#ysch2_zhang-cost"] = "障：是否弃置一张黑色牌，令一名角色装备一张【护心镜】",
    ["ysch2_zhu"] = "诛",
    [":ysch2_zhu"] = "<a href='rfenghou_ready_skill'>蓄势技</a>，出牌阶段，你可以获得弃牌堆里的一张【杀】，然后令本轮内你的技能视为两个独立的“罚”。",
    ["@@rfenghou_readying:::ysch2_zhu"] = "诛 蓄势中",
    ["rfenghou_ready_skill"] = "<b>蓄势技</b>：一种技能标签，拥有此标签的技能发动后失效，直到牌堆洗切后重置；出牌阶段，你可以弃置三张牌，"..
    "重置一个本轮未发动过的蓄势技。",
    ["ysch2_tian"] = "罚",
    [":ysch2_tian"] = "你使用【杀】的次数上限+1。你不因此技能执行以下一项结束后，可执行未选择过的另一项：1.使用一张【杀】；2.摸一张牌；3.弃置场上一张牌；4.重置此技能。",
    ["#ysch2_tian-prompt"] = "罚：你可以执行你未选择过的一项",
    ["#ysch2_tian-slash"] = "罚：使用一张【杀】",
    ["#ysch2_tian-discard"] = "罚：弃置场上一张牌",
    ["@ysch2_tian"] = "罚",
    ["@ysch2_tian1"] = "Ⅰ",
    ["#ysch2_tian1"] = "使用一张【杀】",
    ["@ysch2_tian2"] = "Ⅱ",
    ["#ysch2_tian2"] = "摸一张牌",
    ["@ysch2_tian3"] = "Ⅲ",
    ["#ysch2_tian3"] = "弃置场上一张牌",
    ["@ysch2_tian4"] = "Ⅳ",
    ["#ysch2_tian4"] = "重置此技能",
    ["ysch2_fa"] = "罚",
    [":ysch2_fa"] = "你使用【杀】的次数上限+1。你不因此技能执行以下一项结束后，可执行未选择过的另一项：1.使用一张【杀】；2.摸一张牌；3.弃置场上一张牌；4.重置此技能。",
    ["@ysch2_fa"] = "罚",
    ["@ysch2_fa1"] = "Ⅰ",
    ["#ysch2_fa1"] = "使用一张【杀】",
    ["@ysch2_fa2"] = "Ⅱ",
    ["#ysch2_fa2"] = "摸一张牌",
    ["@ysch2_fa3"] = "Ⅲ",
    ["#ysch2_fa3"] = "弃置场上一张牌",
    ["@ysch2_fa4"] = "Ⅳ",
    ["#ysch2_fa4"] = "重置此技能",

    ["$ysch2_zhang1"] = "敌人会锁定我，让他们放马过来！",
    ["$ysch2_zhang2"] = "有本事，就跟紧我！",
    ["$ysch2_zhu1"] = "感受我的痛苦！",
    ["$ysch2_zhu2"] = "把他们撕成碎片！",
    ["$ysch2_fa1"] = "一招误判，满盘皆输。",
    ["$ysch2_fa2"] = "我会撕碎你手中的胜利。",
    ["$ysch2_fa3"] = "既然你只懂暴力，我会让你见识真正的暴力！",
    ["$ysch2_fa4"] = "现在看清你的错误了吗？",
    ["$ysch2_fa5"] = "和我一起，惩罚他们！",
    ["$ysch2_fa6"] = "小小蝼蚁。",
    ["$ysch2_fa7"] = "让他们归于大地。",
    ["$ysch2_fa8"] = "夺走他们的一切。",
    ["ysch2__RAMATTRA_win_audio"] = "胜利语音",
    ["$ysch2__RAMATTRA_win_audio"] = "（全场最佳）",
}

--[[local Phoenix = General:new(extension, "ysch2__Phoenix", "west", 4, 4, General.Male)--
Fk:loadTranslationTable{
    ["ysch2__Phoenix"] = "菲尼克斯",
    ["#ysch2__Phoenix"] = "不死鸟",
    ["designer:ysch2__Phoenix"] = "铝&yyuaN",
    ["cv:ysch2__Phoenix"] = "未知",
    ["illustrator:ysch2__Phoenix"] = "无畏契约",
}

Fk:loadTranslationTable{
    ["ysch2_shanguangquqiu"] = "闪光曲球",
    [":ysch2_shanguangquqiu"] = "每轮限两次，你可以快速抛出一张【杀】/【闪】，视为使用或打出【闪】/【杀】。若无人看到，抛出其他牌也可；若有人看到且为真，你弃置其一张牌；否则则作废。",
    ["ysch2_zailaiyiju"] = "再来一局",
    [":ysch2_zailaiyiju"] = "",

}]]--
return extension--